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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
zagzebski
Creator
Creator

Set analysis - range of dates

I want to sum an amount within specificed a specfici year/month time frame.

The fields:

Amount

YYYYMM

I want to sum the Amount field for the max of YYYYMM and the preceding 3 months. I know I could do it the long way by adding Max, Max-1, max-2 and max-3 in separate set analysis expressions but thought there would be some way to do it in one concise expression with set analysis.

Thanks in Advance

Steve

2 Replies
Not applicable

sum({<YearMonth={'<=$(=max(Date#(YearMonth,'YYYYMM')))>=$(=addmonths(max(Date#(YearMonth,'YYYYMM')),3))'}>}Sales)

you might have play with  the date function on top of inner dates depends on how is your field.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Your YYYYMM field can't easlily be calculated with as it is. What you can do is make a date field from it:

Load

    ...some fields...,

   Amount,

   date#(YearMonthField, 'YYYYMM') as YearMonthField

From ...;

Once you've done that you can calculate with the YearMonthField using date functions since the underlying values are dates.

sum({<YearMonthField={'>=$(=monthstart(max(YearMonthField)),-3))'}>} Amount)


talk is cheap, supply exceeds demand