Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all. I have a sample table below
| Cat | Hrs |
| AA | 4 |
| FF | 6 |
| BB | 14 |
| FF | 64 |
| FF | 13 |
| CC | 52 |
| AA | 52 |
| DD | 46 |
| ZZ | 87 |
I am trying to calculate the weighted average of the same category but I am not sure how to do this.
What I have thought of was
SUM(hrs * COUNT(cat)) / COUNT(cat)
However I am not sure how to approach the bold part to get the count of each cat.
My goal is to use this set expression in a bar chart to display the data.
Any help is greatly appreciated, thank you.
Weighted average will always have at least 2 measures, in your case you could just do Avg(Hrs) since you don't have a second measure
this might work -
Sum(Aggr(Avg(Hrs), Cat))
Try this:
sum(Hrs * Aggr(nodistinct Count(Cat),Cat))/count(total Cat)
Regards,
Aditya