Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Zaga_69
Creator
Creator

Expression not working when using IF condition

Hi all,

I want to have a straight table in Qlik which shows 2 columns, 1 dimension (product) and 1 measure which react to the Switch filter (i.e. MTH or YTD).  See expressions below:

IF(SWITCH='YTD', SUM({<Month={"<=$(=max(Month))"}>}Sales), SUM(Sales))

To create the filter Switch i created a data island:

LOAD * INLINE[SWITCH
YTD

MTH];

 

However the expression is not working. I created three different measures to test it:

1. Product

2. Expression for MTH values

3. Expression for YTD values

4. Expression with IF condition for MTH or YTD values

The expression in the column 4 does not work since it does not calculates the sales for all products in the table. However, column 3 shows all values and that is that I want. I suspect, the problem is coming from the data island.

YTD not working.jpg

Any idea?

Many thanks in advance!

Labels (2)
3 Replies
jwjackso
Specialist III
Specialist III

Try IF(GetFieldSelections(SWITCH)='YTD', SUM({<Month={"<=$(=max(Month))"}>}Sales), SUM(Sales))

Zaga_69
Creator
Creator
Author

Hi,

Thanks and but unfortunately it does work  as well 

NitinK7
Specialist
Specialist

Hi,

can you attach here your QVW file?