Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

wnorwood
Not applicable

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
Not applicable

Using a variable in a set expression

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
Not applicable

Re: Using a variable in a set expression

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
Not applicable

Using a variable in a set expression

Hi,

Use this expression for Variable

=Concat(DISTINCT Year,',')

Use this expression

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

Hope this helps you.

Regards,

Jagan.

wnorwood
Not applicable

Using a variable in a set expression

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

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