Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
IE
Contributor II
Contributor II

VARIABLE AS FIELD NAME IN SET ANALISYS

Good afternoon,

I would like to use a variable as field name in a set expression:

vSystem is a variable which I feed with a list chart and can be 1,2 or 3.

I need to use it like these expresions:

Sum({<vSystem={"1"}>} Quantity)

or 

Sum({<$(vSystem)={"1"}>} Quantity)

But doesn´t work.

Thanks in advance.

 

 

 

 

 

Labels (1)
  • Other

3 Replies
Vegar
MVP
MVP

Try using an IF statement instead.

if($(vSystem)=1, Sum(Quantity))

 

Digvijay_Singh

I don't use expressions in left size of set analysis but I was curious to test it, I wanted to do it when I saw @rwunderlich  post few months back https://qlikviewcookbook.com/2022/03/expression-as-left-side-of-set-modifier/ but couldn't get chance to do that.

It worked for me though, hope you don't have '=' before the value of your variable

Digvijay_Singh_0-1661398466410.png

Digvijay_Singh_1-1661398493057.png

Digvijay_Singh_2-1661398573671.png

 

 

marcus_sommer

It will work if your variable contained a valid field-name respectively the expression returned a valid field-name - anything else won't work. A valid field-name means further that values which contain any space or special char are wrapped with quotes or brackets like "Field A" or [Field X] respectively that's called in this way like:

sum({< [$(var)] = {'x'}>} value)

- Marcus