Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

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
MVP
MVP

Re: Set analysis with a variable

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

5 Replies
MVP
MVP

Re: Set analysis with a variable

Hi,

Try like this

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

Regards,

jagan.

Not applicable

Re: Set analysis with a variable

Hi Jagan

Just tried but no luck.

MVP
MVP

Re: Set analysis with a variable

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

Re: Set analysis with a variable

Try this:

Define your variable,

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

Then use it where you need it,

$(vSales('2007'))

Not applicable

Re: Set analysis with a variable

Perfect - that works!

Much appreciated.

Regards

Revlin

Community Browser