Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis with a variable

Hi all


Using set analysis, basic example below:

=sum({$ < Year={2007} >} Sales)


However, what I would like to do is instead of having the 2007 as an actual value I would like it to be based
on the value of a variable say called var_year.

I have tried:


=sum({$ < Year={var_year} >} Sales)

and I have tried:


=sum({$ < Year= var_year >} Sales)


But no luck. Any idea on how I can get this to work?

Thanks

Revlin

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi Revlin,

If the variable as a numeric value like 2009 or 2010 then the following should do

=Sum({< Year = {$(var_year)} >} Sales)

Hope that helps.

Miguel

View solution in original post

5 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

=sum({$ < Year={'=$(=var_year)'} >} Sales)

Regards,

jagan.

Not applicable
Author

Hi Jagan

Just tried but no luck.

Miguel_Angel_Baeyens

Hi Revlin,

If the variable as a numeric value like 2009 or 2010 then the following should do

=Sum({< Year = {$(var_year)} >} Sales)

Hope that helps.

Miguel

Not applicable
Author

Try this:

Define your variable,

vSales=sum({$ < Year={$1} >} Sales)

Then use it where you need it,

$(vSales('2007'))

Not applicable
Author

Perfect - that works!

Much appreciated.

Regards

Revlin