Forum Discussion
Having Trouble Creating a Rolling Aggregated Average
Hi,
I suppose you have a table with a column for NAMES and for a MONTH. Let's call that table PEOPLE.
You probably have Headcount = CALCULATE(count(People[NAMES])) which will return the number of names per month.
Now try to make measure .... (this will count the running total for all headcount up till a certain month)
RunTotHeadcount = calculate(
count(People[NAMES]);
filter(
ALL(People);
People[month]<=max(People[month])
)
)
and measure.... (this will return a running total of months passed)
RunTotMonth = calculate(
DISTINCTCOUNT(People[month]);
filter(
ALL(People);
People[month]<=max(People[month])
)
)
And finally this will add up to the measure with the answer you need:
avgHeadcountYTD = [RunTotHeadcount]/[RunTotMonth]
Maybe there is an average function that does all this in one step, but I like to break it down :)