Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
warrenpress
Contributor
Contributor

using variable in place of dimension in set analysis


Hi,

I currently have the following expression

sum({$<L4L_Flag_2014={'Y'}>} qty)

which i need to make dynamic using a variable called L4L_Flag

L4L_Flag is set using the follow expression

if(Year=2014,L4L_Flag_2014,L4L_Flag_2013)


How do i replace the L4L_Flag_2014 dimension in the initial expression with the variable L4L_Flag ??

I tried sum({$<$(L4L_Flag)={'Y'}>} qty) but to no avail.

Thanks in advance

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Just put '=' in variable declaration.

View solution in original post

10 Replies
tresesco
MVP
MVP

Define your variable as string like:

L4L_Flag =if(Year=2014, 'L4L_Flag_2014', 'L4L_Flag_2013')                     // encolsed withing quotes

jagan
Luminary Alumni
Luminary Alumni

Hi,

Give single quotes for L4L_Flag_2014 and L4L_Flag_2013 dimensions in variable, so that it is considered as text, instead of Dimension in variable.


if(Year=2014,'L4L_Flag_2014','L4L_Flag_2013')

now in expression try like this

sum({$<$(L4L_Flag)={'Y'}>} qty)


Hope this helps you.


Regards,

Jagan.

warrenpress
Contributor
Contributor
Author

Thanks tresesco.

I have tried enclosing the dimension in quotes within the variable and it still does not work.

warrenpress
Contributor
Contributor
Author

Thanks tresesco & Jagan.

I have tried enclosing the dimension in quotes within the variable and it still does not work.

tresesco
MVP
MVP

You must select a Year and check if it works. Else, try to share your sample qvw.

sudeepkm
Specialist III
Specialist III

well as a work around you may create two expression with conditional display.

sum({$<L4L_Flag_2014={'Y'}>} qty) / / conditional display when Year=2014

sum({$<L4L_Flag_2013={'Y'}>} qty) / / conditional display when Year=2013


however it is good to have the variable being used.

warrenpress
Contributor
Contributor
Author

Sudeep Mahapatra wrote:

well as a work around you may create two expression with conditional display.

sum({$<L4L_Flag_2014={'Y'}>} qty) / / conditional display when Year=2014

sum({$<L4L_Flag_2013={'Y'}>} qty) / / conditional display when Year=2013


however it is good to have the variable being used.

Thanks.

Unfortunatley i cannot do this as i need to do this update to approx 1000 expressions on 200+ charts

warrenpress
Contributor
Contributor
Author

example attached

tresesco
MVP
MVP

Just put '=' in variable declaration.