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: 
Anonymous
Not applicable

RangeAvg accumulating per Month in Actual Year

Hello,

I need to make an average using the RangeAvg function, accumulating the values of the current year until previous month (if the current month is 6, until the month 5), my fact table has data by customer and a indication of which month this result refer (Column Month) and a Column Year too. Can I use the RangeAvg function for this case? Someone can show me an example?

Best Regards.

4 Replies
petter
Partner - Champion III
Partner - Champion III

If you have the Year and Month in two separate fields you should be able to do like this:

If( Year < Year( Today() ) OR ( Year = Year( Today() ) AND Month < Month( Today() ) ),  RangeAvg ( Above( Sum( Sales ) , 0 , RowNo() ) ) )

petter
Partner - Champion III
Partner - Champion III

2015-06-10 #1.PNG

Anonymous
Not applicable
Author

Thanks for you reply!

But in my chart i don't have the Year and Month Column, only the Client Name need to appear in this object. It's possible to use RangeAvg in this situation?

petter
Partner - Champion III
Partner - Champion III

Yes you can but you don't use RangeAvg() you use the regular Avg() with a Set Expression:

   Avg( { < Year = {'$(=Year( Today() ) )'},Month={"<$(=Num( Month( Today() ) ) )"} > } Val )

The Set Expression picks out the current year and all months before the current to be used as basis for calculating the average.

A prerequisite is that the customer has his/hers values already aggregated to the month level as you said you had. If not you will have to have an Aggr()  added which makes the expression even more complicated.