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

Average of current month and previous month

I'm trying to create a variable that takes the average of a metric (lodgements) for the current month and previous month.

This is the forumla I have so far. I'm not sure why it's not working. Can someone please assist? Thank you.

if(count(DISTINCT [Fin Period]) = 1, (sum({$ <[Fin Period] = {"<=$(vMaxFinPeriodComp)"} - {"<$(vMinFinPeriodComp)"},[Fin Year]=,[Fin Month]=, [Fin Week]=>}$(vLodgements)

 

vMinFinPeriodComp=

date(AddMonths(max([Fin Period]

),-1),'YYYYMM')

 

vMaxFinPeriodComp=

Max([Fin Period]

)

1 Reply
er_mohit
Master II
Master II

Try this

sum({<[Fin Year]=,[Fin Month]=, [Fin Week]=,

[Fin Period]={">=$(=addmonths(monthend(max([Fin Period]))+1,-2)) <=$(=max([Fin Period]))"}>}lodgements)