Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
sravankumarkaturi

Multiple If conditions

Hi All,
I have a tricky situation need help
giving an example of my requirment

I have field 'Type'

Type

A

B

C

D

E

F


If A or B are selected sum(current month sales)/Total sales

if A and B are selected should show combined value


if C or D are selected sum (previous month sales)/ total sales

if C and D are selected should show combined value

If E and F or both are selected there is no calculation so do nothing

and cross selection is done like A and C or B and D and so on do nothing

I have written something like this (please ignore bracket errors and upper/lower case) its working for only one selected value like if one of A/B is selected it works and if A and B are selected shows nothing
similarly if one of C/D is selected it shows value if both are selected shows nothing

need see individual selections and also combined

if(GetFieldSelections([Type]) = 'A' or GetFieldSelections([Type] ) = 'B',((sum ([current month sales]))/ [Total sales]

,

if(GetFieldSelections([Type]) = 'c' or GetFieldSelections([Type] ) = 'D',((sum ([Previous Month sales]))/Total sales


need help on this

Thanks - sravan

1 Solution

Accepted Solutions
Anonymous
Not applicable

Try

if(GetSelectedCount(Type)>0,

if(SubStringCount(Concat(Type, '|'),'A')+SubStringCount(Concat(Type, '|'),'B')>0,

    (sum ([current month sales])/ [Total sales],

     if(SubStringCount(Concat(Type, '|'),'C')+SubStringCount(Concat(Type, '|'),'D')>0,    

               sum ([Previous Month sales])/Total sales)),)


View solution in original post

5 Replies
Anonymous
Not applicable

Try

if(GetSelectedCount(Type)>0,

if(SubStringCount(Concat(Type, '|'),'A')+SubStringCount(Concat(Type, '|'),'B')>0,

    (sum ([current month sales])/ [Total sales],

     if(SubStringCount(Concat(Type, '|'),'C')+SubStringCount(Concat(Type, '|'),'D')>0,    

               sum ([Previous Month sales])/Total sales)),)


sravankumarkaturi
Author

Hi Wallo,Thanks for the reply

It actually worked , i should say almost
if i select A or B or both i get the result thats what i want but if i select A and C or A and D and so on then also its showing the values which it should not show because A and B are one category and C and D are another
cross selections should not give the result

Thanks- sravan

Anonymous
Not applicable

Do you have a field in the data that groups the Types together?  Something like

Type          Group

A               1

B               1

C               2

D               2

Then you would just add a check for that.  Somethiing like

if(GetSelectedCount(Type)>0 and GetPossibleCount(Group)=1,

if(SubStringCount(Concat(Type, '|'),'A')+SubStringCount(Concat(Type, '|'),'B')>0,

    (sum ([current month sales])/ [Total sales],

     if(SubStringCount(Concat(Type, '|'),'C')+SubStringCount(Concat(Type, '|'),'D')>0,   

               sum ([Previous Month sales])/Total sales)),)

dhavalvyas
Contributor III
Contributor III

but where to write this expression with condition ?

In calculation condition inside general tab or in expression tab ?

Anonymous
Not applicable

Depends how you want to see it.  I would think you could put it in the expression tab as an expression.  Or it could be in a text object. 

Or you could put it in an expression and a condition to only show something when rule is met.