Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
bijoylalu
Contributor

How to apply selection to a Variable

Hi,

             I have a variable $(SumOfAmount), which is assigned with an aggregate function( SumOfAmount = Sum(AMOUNT)). How can we apply a selection to the variable "$(SumOfAmount)" without editing the definition of "$(SumOfAmount)".

            Attaching a application which i tried.

           Please advise.

1 Solution

Accepted Solutions

Re: How to apply selection to a Variable

May be this:

Sum({<[PERIOD_CODE]={'02'}>}Aggr($(SumOfAmount), PERIOD_CODE))

4 Replies
dineshraj
Contributor

Re: How to apply selection to a Variable

Hi Bijoy,

I suggest you to use if condition.

if(<Selection_Field>='Selection_Name',$(Variable_Name))

Thanks and Regards.

jayaseelan
Contributor III

Re: How to apply selection to a Variable

Hi Bijoy,

  Try if Condition in your expression you will get your output. In variable you used sum again you using sum in expression, so may some cases it will not work. Use following expression.

if([PERIOD_CODE]='02',$(SumOfAmount))

I have attached the QVF app, PFA.

Thanks,

ift_isabelle
Contributor II

Re: How to apply selection to a Variable

Why would you take away the power of Qlik Sense?

My Solution would be: Make a Master Metric where you sum "Amount" and only select period 2 with set Analysis.

Like this: Sum({1<[PERIOD_CODE]={02}>} AMOUNT)

(If you change the '1' to '$' it will change when you change the dimension. With 1 it stays static, like it is now.)

Re: How to apply selection to a Variable

May be this:

Sum({<[PERIOD_CODE]={'02'}>}Aggr($(SumOfAmount), PERIOD_CODE))