Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

New Contributor III

if clause in a variable

Howdy!  In short, I want bring in a different month for  the measure  defined in my if statement in my variable.

my expression is the following  Sum({<MonthNum={$(=(vMonth_adj))}>}  $(cost_adjusted))/

my month variable vMonth_adjusted  is defined as  if(Measure= 'WSK var cost',  Concat(DISTINCT [MonthNum], ',')+1,  Concat(DISTINCT [MonthNum], ',') )

apparentl tihs expression does not work? I would appreciate your help.

(Meanwhile when vMonth is defined as  =Concat(DISTINCT [MonthNum], ',')    it works fine!)

Tags (5)
3 Replies
Honored Contributor II

Re: if clause in a variable

may be

if(Measure= 'WSK var cost',  Concat(DISTINCT [MonthNum] +1 , ','), Concat(DISTINCT [MonthNum], ',') )

Learning never stops.

Re: if clause in a variable

Can you show image of this?

if(Measure= 'WSK var cost',  Concat(DISTINCT [MonthNum], ','))

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
MVP & Luminary
MVP & Luminary

Re: if clause in a variable

This part: if(Measure= 'WSK var cost' within your variable won't be evaluated on row-level because it is part of an adhoc-variable which will be evaluated global before the chart is calculated and applied on each row. Quite probably there are more han one value for Measure available and without an aggregation on the field it will return NULL.

Further concat() will return a string if more than one MonthNum is available and adding with 1 will also return NULL. What is the aim for + 1?

- Marcus