Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

vivian_kta
New Contributor

Make use of existing variable with new condition

Hi all,

I have a repeated expression which I put as a variable:

vAmt=sum({<Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"}>}[Import Value])

Then I have a very similar expression, just one more condition :

sum({<Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"},[Wholesales/Retail]={'Retail'}>}[Import Value])

Is it possible to make use of the above variable (vAmt) to combine with modifier [Wholesales/Retail]={'Retail'} in the second expression? I'm not sure how the modifier should be nested or what syntax should be. Appreciate any help.

2 Replies
felipedl
Valued Contributor III

Re: Make use of existing variable with new condition

Hi Vivian,

It depends actually, what kind of behaviour do you need?

If you want to get different expressions for differente graphs, something like this might work, but you'll need to check your condition.

vAmt=sum({<$(vSetAnalysis)>}>}[Import Value]) 

Create another variable with something like this:

vSetAnalysis=if(GetObjectField(0)='Dimension Field Name',Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"},[Wholesales/Retail]={'Retail'},Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"})


That should set the vSetAnalysis to the second expression you need when your first dimension used on the chart is called 'Dimension Field Name'.

Otherwise, it gets the first expression.

neelamsaroha157
Valued Contributor II

Re: Make use of existing variable with new condition

You can also create a variable as vSum = sum({<Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"}, $1>}[Import Value])

and pass the value of $1 while using the variable like

=$(vSum([Wholesales/Retail]={'Retail'}))