Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional Expression

Hello,

I have a straight table where I want to put a condition on 4 of the expressions to say if these month are selected then show. I am able to do it for if just one month is showing i.e (Month=1) however I want to say if Month=(1,2,3) then show.

Thanks in advance.

Labels (1)
1 Solution

Accepted Solutions
Not applicable
Author

Try the below expression in condition


=if(GetFieldSelections(Month)=1 and GetFieldSelections(Month)=2 and GetFieldSelections(Month)=3, 1, 0)

Thank you

Vardhan

View solution in original post

11 Replies
marcus_sommer
MVP
MVP

Try getfieldselections() and/or getfieldselectionscount() to read or count the current selections.

- Marcus

sujeetsingh
Master III
Master III

=if(GetFieldSelections(Months)=1 or GetFieldSelections(Months)=2 or GetFieldSelections(Months)=3,Year,Week)

something like this can help you .

Not applicable
Author

Neither of these work but thanks

marcus_sommer
MVP
MVP

Try it again - generally it will work. Perhaps you could also use a simple count-function about the month: if(count(distinct Month) = 3, true(), false())

- Marcus

Not applicable
Author

Try the below expression in condition


=if(GetFieldSelections(Month)=1 and GetFieldSelections(Month)=2 and GetFieldSelections(Month)=3, 1, 0)

Thank you

Vardhan

luis_pimentel
Partner - Creator III
Partner - Creator III

That would work with ORs instead of ANDs.

MK_QSL
MVP
MVP

You want this condition for whole chart/table or for particular some field or expression?

For whole Chart/Table use below in

Layout

Show - Condition

Month = 1 or Month = 2 or Month = 3

Or Try Below

=GetFieldSelections(Month) = 1 or GetFieldSelections(Month) = 2 or GetFieldSelections(Month) = 3

For Particular Expression...

Try as below

=IF(GetFieldSelections(Month) = 1 or GetFieldSelections(Month) = 2 or GetFieldSelections(Month) = 3,  SUM(Sales)))

Not applicable
Author

Anna,

If you want the months 1, 2 and 3 to be selected to perform an action, you may simply do:

if( substringcount( concat(distinct Month, ','), '1,2,3') =1, your action or everything you want)

Concat() will create a string. Substringcount() will return 1 if OK, 0 if it does not find (in fact, this function returns the number of times it finds the expression)

Fabrice

Not applicable
Author

Vardhan A Thank You this works.

However I also want it to show if all 3 are selected can I do that in the same condition?