Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
william_fu
Creator II
Creator II

Calculate measure 4 months backward?

How can I calculate a measure that's always looking 4 months backwards?

i.e. October/17 in the chart needs to reflect the measure from June/17

5 Replies
Anonymous
Not applicable

In your expression add set analysis to show "month - 4"

i.e.

Sum({$<Month={'$(=Month-4)'}, Month=>} YourCalculation)

william_fu
Creator II
Creator II
Author

I tried the following and it didn't work:

Count({$<IndDesemb={'S'},DtInc-={'1/1/1900'},

[DtInc.autoCalendar.Month] ={'$(=[DtInc.autoCalendar.Month]-4)'},

[DtInc.autoCalendar.Month]=>} NroProposta)

Does it have to do with using autocalendar fields?

I also tried using the AddMonths function with no success

MK9885
Master II
Master II

In your script create a Flag which will be Dynamic always

if(InMonth(DtInc, today() ,-4), 1, 0) as Last4Flag,

In front end use

Count({$<IndDesemb={'S'}, Last4Flag= {1}>} NroProposta)

Anonymous
Not applicable

Try:

Count({$< IndDesemb={'S'}, DtInc={'1/1/1900'}, [DtInc.autoCalendar.Month]={'$(=[DtInc.autoCalendar.Month]-4)'}>}, NroProposta)

The last part stops the calculation looking at month selection so removing this should do it.

[DtInc.autoCalendar.Month]=>} NroProposta)

Anonymous
Not applicable

Try

Count({$<IndDesemb={'S'},DtInc-={'1/1/1900'},

[DtInc.autoCalendar.Month] ={'$(=addmonths(max([DtInc.autoCalendar.Month]),-4)'},

[DtInc.autoCalendar.Month]=>} NroProposta)

The format of your month field could be an issue.  So you have some sample data?  you may have to do something like date(addmonths(max([DtInc.autoCalendar.Month]),-4),'M/D'YYYY')