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: 
Not applicable

If statement Previous Month

hi i have the following If statement and would like to further develop it to include only the previous months total.

Sum(Aggr(If((inLeveransDatum - Lev_Leveranstid)> Villkor_inlev, 1, 0), [%InLevNr]))

the Month field is called InLeveransDatumMonth

any help is greatly appreciated.

Best

Brad

1 Reply
Anonymous
Not applicable
Author

Hi,

You can try something like below.

SUM(

     AGGR(

               IF(InLeveransDatumMonth = $(PreviousMonth) and

                 (inLeveransDatum - Lev_Leveranstid)> Villkor_inlev, 1, 0)

     , [%InLevNr])

     )

To get the previous Month variable have the previous month.

Have a month number field created in your dataset if its not existing already. For efficient result i suggest you have the month number field like... 201301, 201302, 201303....

Considering you have the month number field like above.

Table1:

Load Distinct Max(MonthNumber,2) as MonthNumber Resident Calendar;

LET PreviousMonth = Peek('MonthNumber', 0, 'Table1');

DROP Table Table1;

And in your IF condition also use the month field which is numeric.

hope this helps.

Regards,

Aadil