Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have read many questions here about rolling measures and tried different solutions but still cannot get my table right.
I have a simple dataset attached here. There is three different products with sales by month (YYYY-MM). I have loaded this data in Qlik sense like this:
Then I tried many of different codes to get that sales rolling 12 month. This is the last one I tried:
Avg({<YearMonth = {"$(='>=' & Date(MonthStart(Max(YearMonth), -12), 'YYYY-MM') & '<=' & Date(Max(YearMonth), 'YYYY-MM'))"}>}Sales)
But somehow I always manage to get only one month sales by YearMonth and my goal is to get it show sales in table like this:
So the table where for each row there is Product, YearMonth and the sum of sales from this YearMonth 12 months back. Is there something I need to do in the loading code? Or how is it possible to get that sum of twelve month showing by month?
Hi @ELZ
It will be possible to get in Set Analysis, But i always tend to make a flag in Script for thing like this and normally make it part of my calendar.
Here is what i use, would need to be tweaked.
IF(TempDate <= MONTHSTART(TODAY(1))-1 AND TempDate >= ADDMONTHS(MONTHSTART(TODAY(1)),-12),1) AS F_ROLLING_12_MONTHS,