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

Trying to find the Max of an aggr({<,dim= >},dim), but dim= } being ignored

I have a function in a text box
=max(aggr({$<PeriodCounter = {">$(#=max(PeriodCounter-12))<=$(#=max(PeriodCounter))"},[$Year Month]= >} sum([SalesAmount]),[$Year Month]))
but instead of the max value over the last 12 periods being returned I always get the value for the currently selected period [$Year Month]
If I select several [$Year Month]s I get the max of the months selected.
I can't understand why [$Year Month]= is not being honoured?
Any help appreciated
1 Solution

Accepted Solutions
danielrozental
Master II
Master II

You should try something like this

max(

{$<PeriodCounter = {">$(#=max(PeriodCounter-12))<=$(#=max(PeriodCounter))"},[$Year Month]= >}

     aggr(

          sum({$<PeriodCounter = {">$(#=max(PeriodCounter-12))<=$(#=max(PeriodCounter))"},[$Year Month]= >}

               [SalesAmount]

               )

     ,[$Year Month])

)

View solution in original post

3 Replies
danielrozental
Master II
Master II

You should try something like this

max(

{$<PeriodCounter = {">$(#=max(PeriodCounter-12))<=$(#=max(PeriodCounter))"},[$Year Month]= >}

     aggr(

          sum({$<PeriodCounter = {">$(#=max(PeriodCounter-12))<=$(#=max(PeriodCounter))"},[$Year Month]= >}

               [SalesAmount]

               )

     ,[$Year Month])

)

Not applicable
Author

Daniel - you are a gentleman and a scholar!  Fantastic! Thanks  I've been pulling my hair out over this one.

Regards

Matthew

Not applicable
Author

Thanks Daniel, absolutely great, worked first time, much appreciated

Regards Matthew

Sent from my iPad