Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Averange from the last 12 months

I've got table looking like this:

ReadingDate,=avg(Cost)

,£189.56

11/04/2011,£10.00

28/05/2011,£326.00

02/06/2011,£12.00

28/06/2011,£53.00

10/09/2011,£956.00

11/10/2011,£63.00

01/01/2012,£36.00

11/04/2012,£150.00

12/05/2012,£100.00

and i am able to make averange of single date, but how to make averange of the year, but not from january to december, but from ex. from may last year to may this year, so from the last 12 months?

11 Replies
ramoncova06
Specialist III
Specialist III

this will do it assuming you do have a valid date format


=Avg( {$<Date = {">=$(=AddMonths(Max(Date),-12)) <=$(=Max(Date))"} , NaN-={''NaN'}>} NaN)


if you have another date format let me know so I can tweak it the format to resemble yours



* Edited since I noticed that was missing the max(date) in the rolling last 12 months

Anonymous
Not applicable
Author

try  this

AVG({$<ReagingDate = {"<=$(=addmonths(max(ReagingDate),-1))>=$(=addmonths(min(ReagingDate),-12))",NaN-={'NaN'}}>}Cost)