Weighted Average of Averages by selection from a filter on a chart
Hi there;
I have some aggregated data (example in table below) I have already calculated the averages and also brought in the counts to hopefully enable what I want to do. It is partially working but not 100% how I want to (may not be possible? or I am very close but missing something)
week
event type
worked_days (this is an avg)
week_counts
(count of event which avg is based on)
03/01/2022
event_a
2
2
10/01/2022
event_a
1.67
6
17/01/2022
event_a
1.2
5
24/01/2022
event_a
2.33
3
31/01/2022
event_a
2
1
I have a qlik chart and the dates listed. My chart has filters of week, and event type (there are more event types this example is just the same event)
So using the standard
=Sum(worked_days*week_counts)/Sum(week_counts)
I get worked_days displaying as is on the chart (if I combine with another event it seems to work OK in terms of weighted avg btw).
Its almost like I want a rolling cumulative avg based on selection
i.e. if I select three dates, it plots 1 data point as the first mean, then the 2nd data point as the weighted mean of the two, then the third data point as the weighted mean for the three selected dates (not necessarily consecutive dates, any selected dates - all my dates are start_of_week dates)
i.e. in the chart I ideally would like the first data point would be 2,
second would be 1.75 =(2*2 + 1.67*6)/(2+6)
third would be 1.54 =(2*2 + 1.67*6 + 1.2*5)/(2+6+5)