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

Help needed with rolling (cumulative)AVG

Hi everyone

Can someone help me do this operation?

the month is a dimension that it could be anything (year, week....)

and it is a range of months that i pick from my filtres "sheet" so it is not something static

Shall i use a pivot or a single table? and i have no problem if the calculations take place horizontal or Vertical .

I just want to do them [:P]

This is one dimension Count = 1Count = 2Count = 3Count = 4Count = 5Count = 6
MonthOct09Nov09Dec09Jan10Feb10Mar10
Sum(Sales)AVGSum(Sales)AVGSum(Sales)AVGSum(Sales)AVGSum(Sales)AVGSum(Sales)AVG
CustA30306547,58961,334557,251548,804548,17
CustB40403537,55543,335546,252542,007848,00
CustC505028391029,336538,253537,606542,17
This is the SUM of (10+28+50)/3This is the SUM of (35+65+10+28+50)/5This is the SUM of (35+65+10+28+50+65)/6


THANK YOU VERY MUCH

1 Solution

Accepted Solutions
Not applicable
Author

My friends thank you for the answer I found it

and it is working perfectly

rangesum(before(SUM([SALES]),0,columnno(TOTAL)))/columnno(TOTAL)

View solution in original post

5 Replies
Not applicable
Author

You've essentially described a pivot table.

Is there some part of the pivot table implementation you need help with?

Not applicable
Author

I just re-read your post, and I missed the 'cumulative' part of the request.

You could achieve the cumulative average using set analysis, and descriving the average calculation as the average of all sales for everything in the selection described as current and prior to, as opposed to the default functionality wich is to average only those fact values that meet both dimension criteria.

However, this won't actually do exactly what you've described. As opposed to the averages of the totals, you'll actually get the average at the individual sales level.

Not applicable
Author

Hi and thank you for the interest to help.

I have 1 question. As you mentioned the "prior to" and "current" i assume that is something like the "before" and "after" statements?

Is there any statement that collects the SUM of columns dimensions (before or after) instead than the previous only or next?

and if not is there any possibility to somehow do a smart Loop operation to gather these values?

Not applicable
Author

i found one nice trick so far. in order to get the cumulative count of "Dimensions" we can use the columnno(TOTAL)

Now what is left is to get the cumulative sum of sales through dimensions

Not applicable
Author

My friends thank you for the answer I found it

and it is working perfectly

rangesum(before(SUM([SALES]),0,columnno(TOTAL)))/columnno(TOTAL)