Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I lost grasp of an old formula 2

Status
Not open for further replies.

Ladyazh

Programmer
Sep 18, 2006
431
US
I had been using code written by one of the members here.
(
if {?par} <> "ALL" then
{t.CODEID} = {?param}
else
if {?par} = "ALL" then
true
)
I had modified it and it worked all the time until now when I am facing an issue as follows:
Sample Data:
CODEID CODETYPE
A 3
B 3
C 3
A 1
B 1
C 1
A 4
B 4

I need to say if CODETYPE = ALL - give me everything as shown above in sample data.
If CODETYPE = 3 - give me only following.
CODEID CODETYPE
A 3
B 3
C 3

I am stuck. Please, push me in a right direction. Thanks
 
I forgot to mention.
CODEID CODETYPE
A 3
B 3
C 3
CODETYPE=3 group's CODEIDs should not be mixed with CODETYPE=1 and CODETYPE=4 CODEIDs.

A 1
B 1
C 1
A 4
B 4

___________________________________

I was trying this unsuccessfully:

(
if {?param} <> "ALL" then
({t.CODETYPE}=3
and
{t.CODEID} = {?param})
else
if {?AccountType} = "ALL" then
{t.CODETYPE}=3
)
 
Sorry it was suppose to be

I was trying this unsuccessfully:

(
if {?param} <> "ALL" then
({t.CODETYPE}=3
and
{t.CODEID} = {?param})
else
if {?param} = "ALL" then
{t.CODETYPE}=3
)
OR
(
if {?param} <> "ALL" then
({t.CODETYPE}=1
and
{t.CODEID} = {?param})
else
if {?param} = "ALL" then
{t.CODETYPE}=31
)
OR
(
if {?param} <> "ALL" then
({t.CODETYPE}=4
and
{t.CODEID} = {?param})
else
if {?param} = "ALL" then
{t.CODETYPE}=4
)


 
Hi,
Well that was confusing...

Are you passing a CODETYPE or a CODEID in the parameter?

What exactly do you mean by
CODETYPE=3 group's CODEIDs should not be mixed with CODETYPE=1 and CODETYPE=4 CODEIDs.

Instead of the seelction formula, can you show ( as a sample) what results are expected with the various parameter values you may pass?






[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I am sorry for the confusion, I can not get it straight in my head maybe this is why I can't work it out.
Tis is Sample Data:
CODEID CODETYPE
A 3
B 3
C 3
A 1
B 1
C 1
A 4
B 4


There are 3 parameters:

for group where CODETYPE=3 parameter is {?param1}
for group where CODETYPE=1 parameter is {?param2}
for group where CODETYPE=4 parameter is {?param3}

is it better?


 
Hi,
Somewhat, but I still do not 'get' what you
are referencing by 'Group' nor can I see why 3 parameters..Your example did not show what you expect to se with some sample values for the param( or params)..




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
What I meant by
CODETYPE=3 group's CODEIDs should not be mixed with CODETYPE=1 and CODETYPE=4 CODEIDs.
is that :
As and bs and Cs from group CODEID and CODETYPE=3 can not be mixed up with
As and bs and Cs from group CODEID and CODETYPE=1 can not be mixed up with
As and bs and Cs from group CODEID and CODETYPE=4.

But if CODETYPE="ALL" (it is a number so it will be tricky)
then all filters should be ignored and all data should be displayed.

 
I see, I will try different approach here.

Here is data as we saw it before

"GroupThree" is
CODEID CODETYPE
A 3
B 3
C 3
"GroupOne" is
CODEID CODETYPE
A 1
B 1
C 1
"GroupFour" is
CODEID CODETYPE
A 4
B 4

User should be able to select CODETYPE3, CODETYPE2, CODETYPE4 or ALL CODETYPEs (then all data will come up).
Within CODETYPEs user may select As or Bs or Cs or ALL CODEIDs or combination of any. If ALL selected then only whole group will come up.

is this clearer? Thanks
 
Hi,
Closer to understanding now,..

What is
'group CODEID' in reference to? - there is no group named COEID..How is "GroupOne" or any of those determined?

Try something like:
Code:
If
(
 {?CodeTypeParam} = 'ALL' [COLOR=green]// ( If numeric make it 0)[/color]
and
 {?CoeidParm} = 'ALL' [COLOR=green] // same comment [/color]
) then 
True               [COLOR=green]   // Return everything..[/color]

Else 
  If ( {?CodeTypeParam} = 'ALL'  and {?CoeidParm} <> 'ALL' )
   Then
       COEID = {?CoeidParm}
  Else 
   If ( {?CoeidParam} = 'ALL'  and {?CodeTypeParm} <>'ALL' )
   Then
       CODETYPE = {?CodeTypeParm}



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Hi,
OOPS, forgot to test for one more possibility:

Code:
If
(
 {?CodeTypeParam} = 'ALL' // ( If numeric make it 0)
and
 {?CoeidParm} = 'ALL' // same comment 
) then 
True                  // Return everything..

Else 
  If ( {?CodeTypeParam} = 'ALL'  and {?CoeidParm} <> 'ALL' )
   Then
       COEID = {?CoeidParm}
  Else 
   If ( {?CoeidParam} = 'ALL'  and {?CodeTypeParm} <>'ALL' )
   Then
       CODETYPE = {?CodeTypeParm} 

 Else
   If ( {?CoeidParam} <> 'ALL'  and {?CodeTypeParm} <>'ALL' )
  Then
   CODETYPE = {?CodeTypeParm} AND COEID = {?CoeidParm}








[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Maybe I'm missing something, but couldn't you treat this independently and get the same results as in your last solution Turkbear?

(
if {?codeIDparm} <> "ALL" then
{t.CODEID} = {?codeIDparm}
else
if {?codeIDParm} = "ALL" then
true
) and
(
if {?codetypeparm} <> "ALL" then
{t.codetype} = {?codetypeparm}
else
if {?codetypeParm} = "ALL" then
true
)

-LB
 
OMG! Thanks to both of you..I am off to testing all of it!
 
I am not sure we are there yet.
Turkbear,
{?GroupOne}, {?GroupThree} and {?GroupFour} are parameters.
It is purely depends on CODETYPE=1, 3 or 4.

So {?GroupOne} works with CODETYPE=1 and so forth...

I have to tell that there are only 3 CODETYPEs 1,3,4 and several CODEIDs (can grow to whole alphabet)...
********************************************************

I am testing...
 
I think it is working...so far it is!!!
Thank you very much!!!!!!!!!!!!!!!!!!!!!!!
 
Hi,
Glad it got done..
( Yes, LB, your formula is more elegant and most likely faster - nice...)



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
One more here.
Both of my parameters should be excepting multiply values.
I use
join({?CodeID},",")
for the string
but what should I use for the Numeric?

Thank you
 
For the numeric, use a formula like:

numbervar i;
numbervar j := ubound({?CodeType});
stringvar display;

for i := 1 to j do(
display := display + totext({?CodeType},0,"") + ","
);
display

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top