Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum of '11' prior months.

Hello,

I need to create a set Analysis to have the total of the 11 prior months of the current selection.

Here is my code:

sum({$<Reference_Value_Mois= {$(>=Max(Reference_Value_Mois)-11)}>}

  sum(aggr($(vRevisedCabNP_Devise),DLP_NOM,Reference_Value_REG_NOM,Reference_Value_Annee,Reference_Value_Mois))

)

There is two points...

First my main expression is:

sum(aggr($(vRevisedCabNP_Devise),DLP_NOM,Reference_Value_REG_NOM,Reference_Value_Annee,Reference_Value_Mois))

1. Qlik does not alow nested aggregation!

2. What I want to achieve is having on the same line the value for the selected month and next to it the value for the total of the 11 previous months regarding the above expression.

Thank you for your help or advices.

Regards,

Alexandre

3 Replies
whiteline
Master II
Master II

Calculating rolling n-period totals, averages or other aggregations

Qlik allows nested aggregation.

$-sign expansion and set analysis is calculated once for the whole chart. So you can't use it to create rolling calculations.

Not applicable
Author

Hello,

Thank you for the link.

But I need to calculate the value not in a table, but in a field (text object) for further calculations.

When I use the following expression I do recieve the message:

''Nested aggregation not allowed''

=sum({<Reference_Value_Mois={'>=$(=only(Reference_Value_Mois)-11)<=$(=only(Reference_Value_Mois))'}>}

  sum(aggr($(vRevisedCabNP_Devise),DLP_NOM,Reference_Value_REG_NOM,Reference_Value_Annee,Reference_Value_Mois)

  )

  )

Alexandre

whiteline
Master II
Master II

It's because you use two nested Sum() functions.