Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have seen several postes about displaying a date range, but am still having some trouble with it and was hoping for some help. I have a bar chart, using Month.YearMonth as the dimension and TotalSales as the measure. Want to limit the dates to on the x-axis to only show the last twelve months or 2019-present.
Do I put a calculated expression as the dimension, and remove the Month.YearMonth dimension? Or is there a way to write an expression in the limitation field (Exact value).
I had a requirement for this and solved it by adding the following line to the end of my load script it creates a dimension called _Rolling12 that can be then be used anywhere in the application. (In my case my metric was called PageViews so replace it with your metric)
If( Num(Date) > addmonths($(CurrentDate),-12) and Num(Date) <= Today(),1) as _Rolling12
Then in my bar chart I used the following formula in my metric
Sum(PageViews*_Rolling12)
as my Dimension I used a combination of Year Month from my Master Calendar and in the add-ons section of the bar chart options I unchecked the box that says Include zero values so it only shows the last 12 months and not the months with no totals.
Sorry you need to create a variable in the load script for the current date add this line prior to loading the previous line I posted
Let CurrentDate=num(date(Today(),'YYYYMMDD'));
This should do it but if not let me know, the entire script I use is much more fleshed out and was shown to me at a Qlik Conference I attended about a year or so ago.