I’m trying to replace my Excel sheets with QuickSight and I’m running into an issue while calculating averages.
My data set contains two columns, a “week” and a “users” column. I want to add two calculated fields:
The average of the past 4 weeks
The average of the 4 weeks prior to that
So for instance, for the week “May 18 2024” the average of the past 4 weeks should be (10+18+9+15)/4 = 13 and the average of the 4 weeks prior to that should be (4+9+10+8)/4 = 7.75.
I’ve created the first calculated field with the formula windowAvg(sum({Users}), [{Week} DESC], 0,3) and that works perfectly, but I can’t get the second calculated field to work. I’ve tried windowAvg(sum({Users}), [{Week} DESC], 3,7) but that does not give the answer I expect. Any thoughts on this one?
I’ve created a dashboard with a sample data set in case that helps explain things
Before I come to the solution I will mention two points.
windowAvg is not the solution,. With start and end you can determine the rows that will be included in the calculation. Start means the rows above your original row and end the rows below. It it not possible to use it the way you wanted. See also: windowAvg - Amazon QuickSight
windowAvg(sum({Users}), [{Week} DESC], 4,7) => It is week t-4 till week t-7 instead of t-3 till week t-7, right?
Now lets have a look into a solution:
The first windowAVG would work. An alternative to calc week t-0 to t-3 is: