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: 
wnorwood
Contributor III
Contributor III

Using a variable in a set expression

Hello,

I am new to QlikView and I am trying to do something I think should be easy, but I just can't seem to get it to work.  I want to use a variable in my set expression.  The variable (vslandYear) is set to the the value selected from a list box that uses a data island.

When I use the actual year number like below, the expression works just fine.

=sum({$<DateYear = {2008}>} Sales) 

But, I want to it to work more like this:

=sum({$<DateYear = {$(vIslandYear)}>} Sales)

This results in all 0's in the results.  Can anyone tell me what I am doing wrong?

Thanks!

4 Replies
deepakk
Partner - Specialist III
Partner - Specialist III

hi,

I think you have not intialised the variable correctly.

the Variable should be defiend in either of the two ways.

vIslandYear = 2008

or

vIslandYear  =max(DateYear )

I hope this resolves the issues

Deepak

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     Use vIslandYear=Concat(Distinct DateYear,',');\\If you need to display with all the selected dates.

     vIslandYear=Max(DateYear);\\To get the Maximum year from the selection.

     Use expression as

     =sum({$<DateYear = {$(=vIslandYear)}>} Sales)

Hope it helps

Celambarasan

jagan
Luminary Alumni
Luminary Alumni

Hi,

Use this expression for Variable

=Concat(DISTINCT Year,',')

Use this expression

=sum({$<Year = {$(=vYear)}>} Amount)

Hope this helps you.

Regards,

Jagan.

wnorwood
Contributor III
Contributor III
Author

Thanks for all the help!  Finally got it to work using the following:

=sum({$<DateYear = {$(=Only(IslandYear))}>} Sales)