Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
debsahoo
New 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.

1 Solution

Accepted Solutions
MVP
MVP

Re: How to use variables in expression.

Include Month bifurcation in the denominator like:

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

6 Replies
MVP
MVP

Re: How to use variables in expression.

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
Honored Contributor

Re: How to use variables in expression.

Try this

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

debsahoo
New Contributor III

Re: How to use variables in expression.

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

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



MVP
MVP

Re: How to use variables in expression.

Include Month bifurcation in the denominator like:

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

debsahoo
New Contributor III

Re: How to use variables in expression.

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

MVP
MVP

Re: How to use variables in expression.

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

Community Browser