Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate # of Days Above Average

Hi everyone,

I am trying to create an expression that will calculate the number of days in the month selected which are above a trailing 3-month average. So far this is what I've got:

=Sum(

  Aggr(

  If(

  Sum({<PeriodNumber={$(=Max(PeriodNumber))}>} Value)

  > Avg({<MonthYear=,PeriodNumber={">=$(=Max(PeriodNumber)-2) <= $(=Max(PeriodNumber))"}>} Value)

  ,1,0)

   ,Dept,Date)

  )

Any ideas what I'm doing wrong? I just get Zeros.

2 Replies
MK_QSL
MVP
MVP

=SUM(Aggr(IF(SUM(Value) >= Avg(TOTAL {<MonthYear=,PeriodNumber={">=$(=Max(PeriodNumber)-2) <= $(=Max(PeriodNumber))"}>} Value), 1,0),Date,Dept))

Not applicable
Author

Hi Manish,

Thanks for responding!

That calculates # of days above the overall average. I would like to calculate the number of days above the three-month average for each department. Is that possible?