Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
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?