Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Variable in set analysis

Trying to use a variable in a set analysis expression and I can't figure out the syntax.  It currently looks like

SUM({$<TIME_Year={vMax_Year}>} Employee_Salary)

'vMax_Year' is a variable set to the latest year in my data (2012).

3 Replies
dwh1104
Creator II
Creator II

Try this...

SUM({$<TIME_Year={$(#vMax_Year}>} Employee_Salary)

Thanks,

Dan

Anonymous
Not applicable
Author

Thanks Dan, but it didn't work.  However I did get it to work with

SUM({$<TIME_Year={"$(vMax_Year)"}>} Employee_Salary)

Can you help me understand why?  Do you know of a good resource for set analysis syntax?

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi there,

When you were trying to run your expression without the dollar sign you were effectively mixing syntaxes.  Use of the variable at that point was not valid.  However, when you put a variable in $() what QlikView does is 'swaps out' the dollar sign expanded variable for it's contents.  This would mean that your code would effectively read as:

SUM({$<TIME_Year={"2012"}>} Employee_Salary)

This is then valid syntax.

There are a couple of PDF files on Set Analysis that you should be able to find if you Google for them.

I've uploaded a couple of Set Analysis examples as 'Shared QlikViews' that may be of help:

http://community.qlik.com/qlikviews/1175

http://community.qlik.com/qlikviews/1113

Hope that helps,

Steve