Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

danimelo1
New Contributor III

filter a variable

Hi all,

Is it possible to filter a variable? Eg: vMyvariable = Sum (sales)+Sum(Margin)

Then filter this variable by year:

Sum({<Year = {'2017'}>}vMyvariable)

Regards,

Daniel M

Tags (2)
1 Solution

Accepted Solutions

Re: filter a variable

Thats not possible directly

Sum cannot used against sum again.

The possible way is use the set analysis within the vMyvariable expression. Let me know if you are facing any issues with that.


Try the below, it might be work but not sure


Sum({<Year = {'2017'}>}Aggr(vMyvariable, Year))

3 Replies

Re: filter a variable

Thats not possible directly

Sum cannot used against sum again.

The possible way is use the set analysis within the vMyvariable expression. Let me know if you are facing any issues with that.


Try the below, it might be work but not sure


Sum({<Year = {'2017'}>}Aggr(vMyvariable, Year))

devarasu07
Honored Contributor II

Re: filter a variable

Hi,

Try like this,

1) create a variable like below, let me know if any issues?

Alt(Sales,0)+Alt(Margin,0)

2)  Expression like this

SUM({<Year = {'2017'}>} $(Variable1))

Capture.JPG

giakoum
Honored Contributor II

Re: filter a variable

is Sum(Sales)+Sum(Margin) the same as Sum(Sales+Margin)?

if yes, you can have a variable to hold the 2 fields  as text and use $ to execute :

Variable1 : Sales+Margin

Expression : $(='Sum({<Year = {'2017'}>} ' & Variable1)