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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
ruben_moya
Creator
Creator

Using variable as value in field

Dear Experts,

I've got the following expression in measure in one of my tables:

num(Sum({<AreaContinent={'Canada'} )Total_amount)

I need to store 'Canada' in a variable in the script. I tried SET v.Area=chr(39)&'Canada'&chr(39), but it is not working:

num(Sum({<AreaContinent={$(v.Area)} )Total_amount)

However, the result of calculating $(v.Area) is 'Canada'

 

Could you please give me a handa. Is it actually possible to do it? Thanks

1 Solution

Accepted Solutions
sunny_talwar

How about this

Num(Sum({<AreaContinent={$(v.Area)}>} Total_amount))

or

Num(Sum({<AreaContinent={$(=$(v.Area))}>} Total_amount))

 

View solution in original post

4 Replies
sunny_talwar

How about this

Num(Sum({<AreaContinent={$(v.Area)}>} Total_amount))

or

Num(Sum({<AreaContinent={$(=$(v.Area))}>} Total_amount))

 

ruben_moya
Creator
Creator
Author

Hi Sunny,

 

I couldn't make it work. The thing is, if I put the expression in a table I get the result I need 'Canada', but when I use the same variable as a field value in set analysis it isn't working.

 

Thanks

tresesco
MVP
MVP

I can guess that this could be something related to quotes issue or '=' issue in variable declaration. Could you share screenshots of your variable declaration and expression definition and output for the variable? 

ruben_moya
Creator
Creator
Author

It turns out that the expression Sum({<AreaContinent={Canada} )Total_amount) also works without the quotes ' * '

I just set a variable in the script:

SET v.Areas='Canada';

Then use it in set analysis:

Sum({<AreaContinente={$(v.Areas)} )Total_amount)