
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using Variables in Chart Expressions or Measures
Hi All.
I am quite new to Qlik Sense and trying to calculate Sales from Last Quarter vs This Quarter
So I have a Purchase Amount and a Purchase Date.
I set the following in the load Statement
LET vThisQuarter = 'Q' & Ceil(Month(Today())/3);
LET vLastQuarter = 'Q' & Ceil(Month(Today())/3-1);
Now I am trying to create the formula that will give me Q1 and Q2 sales. I am not sure what to do. Any suggestions.
Thanks,
David
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just use dollar sign expansion to replace the hard coded values with the variable content:
=sum({$<Quarter={'$(vLastQuarter)'}>}sales)
=sum({$<Quarter={'$(vThisQuarter)'}>}sales)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe have a look at this series of blog posts about using set analysis and point in time reporting
The Magic of Set Analysis - Point In Time Reporting • Blog • AfterSync


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please See attached.
It might help you.
thanks
krishna

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is what I tried and it worked. The problem is that hardcodes Q1 and Q2 into the formula. I want to pass a variable so when the Q2 changes to Q3 I dont have to update the formula.
Does this make sense?
Thanks
David


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just use dollar sign expansion to replace the hard coded values with the variable content:
=sum({$<Quarter={'$(vLastQuarter)'}>}sales)
=sum({$<Quarter={'$(vThisQuarter)'}>}sales)
