Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All I am currently using the following to hide/ show a table:
GetFieldSelections([Key Figure]) = 'XYZ' and GetSelectedCount(SALES_LEVEL1)>0 or GetSelectedCount(SALES_LEVEL2)>0 or GetSelectedCount([Sales Employee Name])>0 or GetSelectedCount(Account_Name)>0
This works alongside this in the alternate table:
GetFieldSelections([Key Figure]) = 'XYZ'
and GetSelectedCount(SALES_LEVEL1)=0 and GetSelectedCount(SALES_LEVEL2)=0 and GetSelectedCount([Sales Employee Name])=0 and GetSelectedCount(Account_Name)=0
HOWEVER.......
When a SALES_LEVEL is selected it appears to ignore the 'Key Figure' side of it, so I end up with 2 charts showing at the same time which is strange!!
Any ideas?
Thanks
You need to be explicit about the order in which the and and or's should be evaluated. Perhaps you meant something like this:
GetFieldSelections([Key Figure]) = 'XYZ' and (GetSelectedCount(SALES_LEVEL1)>0 or GetSelectedCount(SALES_LEVEL2)>0 or GetSelectedCount([Sales Employee Name])>0 or GetSelectedCount(Account_Name)>0)
You need to be explicit about the order in which the and and or's should be evaluated. Perhaps you meant something like this:
GetFieldSelections([Key Figure]) = 'XYZ' and (GetSelectedCount(SALES_LEVEL1)>0 or GetSelectedCount(SALES_LEVEL2)>0 or GetSelectedCount([Sales Employee Name])>0 or GetSelectedCount(Account_Name)>0)
The reason why Gysbert is probably right (he usually is) is that all expression operators have an order of precedence when you combine them in the same expression. That means that a multiplication will be executed before an addition, and an 'and' will be evaluated before and 'or'.
If you want to change this behavior, you should use parentheses to group subexpressions, like in he example solution above. Parentheses don't cost you anything in terms of performance or expression complexity. Better to use too many parentheses than too few.
There is a nice document about Qlik expressions here: qlik expressions.docx
See page 3 at the bottom for an operator precedence table.
However, keep in mind that this is not an official Qlik document. I couldn't even find anything like that in the official QlikView documentation (there is one for set analysis operators in the QlikView Reference manual)
Best,
Peter
Thank you, I have the desired result!