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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
debsahoo
Contributor III
Contributor III

How to use variables in expression.

Hello,

Here VSelectedMonth = Month

I have a list box of Month field. The requirement is when I select any month in this list box the variable show that month only and using this variable write a expression to see % of sales in that month of 2010 in a Gauge Chart . I wrote this below expression but its not working please help me out.

=sum({$<Year={"2010"},Month={"=$(=VSelectedMonth)"}>}Sales)/sum({<Year={"2010"}>} Sales)


If I write "=sum({$<Year={"2010"},Month={"Jan"}>}Sales)/sum({<Year={"2010"}>} Sales)" it will work only for January month but I want to use that variable.




Thanks in Advance.

Labels (1)
1 Solution

Accepted Solutions
tresB
Champion III
Champion III

Include Month bifurcation in the denominator like:

=sum({$<Year={'2010'},Month={'$(VSelectedMonth)'}>}Sales)/sum({<Month,Year={'2010'}>} Sales)

View solution in original post

6 Replies
tresB
Champion III
Champion III

If you don't include the field in the set analysis, expression would work on - how you select the values from the field. Hence you could try like:

=sum({$<Year={'2010'}>}Sales)/sum({<Year={'2010'}>} Sales)

Or,

=sum({$<Year={'2010'},Month={'$(VSelectedMonth)'}>}Sales)/sum({<Year={'2010'}>} Sales)

shiveshsingh
Master
Master

Try this

=sum({$<Year={"2010"},Month={"$(=VSelectedMonth)"}>}Sales)/sum({<Year={"2010"}>} Sales)

debsahoo
Contributor III
Contributor III
Author

I try below code it will show 100% for every month.snappp.PNG

=sum({$<Year={'2010'},Month={'$(VSelectedMonth)'}>}Sales)/sum({<Year={'2010'}>} Sales)



tresB
Champion III
Champion III

Include Month bifurcation in the denominator like:

=sum({$<Year={'2010'},Month={'$(VSelectedMonth)'}>}Sales)/sum({<Month,Year={'2010'}>} Sales)

debsahoo
Contributor III
Contributor III
Author

Thank you Tresesco. It works. But unable to understand the code.

tresB
Champion III
Champion III

Learn more about set analysis: Set Analysis: syntaxes, examples