Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Specialist II
Specialist II

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

Highlighted
Creator
Creator

Hi,

Thanks and but unfortunately it does work  as well 

Highlighted
Creator III
Creator III

Hi,

can you attach here your QVW file?