Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I have the following three piece measures
However when there is a gap in dates, the AverageHC returns incorrect value
For example in above the AverageHC displays 17.5 when it should be 14.25
The basis of the calculation is below
Solved! Go to Solution.
Average HC =
var a = ADDCOLUMNS(VALUES(Headcount[Month]),"CHC",var m=[Month] return CALCULATE(sum(Headcount[HC]),Headcount[Month]=m))
var b = ADDCOLUMNS(a,"PHC",var m=[Month] return if([Month]=0,[CHC],CALCULATE(sum(Headcount[HC]),Headcount[Month]=m-1)))
return averagex(b,DIVIDE([CHC]+[PHC],2,0))
Average HC =
var a = ADDCOLUMNS(VALUES(Headcount[Month]),"CHC",var m=[Month] return CALCULATE(sum(Headcount[HC]),Headcount[Month]=m))
var b = ADDCOLUMNS(a,"PHC",var m=[Month] return if([Month]=0,[CHC],CALCULATE(sum(Headcount[HC]),Headcount[Month]=m-1)))
return averagex(b,DIVIDE([CHC]+[PHC],2,0))
User | Count |
---|---|
92 | |
85 | |
77 | |
66 | |
62 |
User | Count |
---|---|
110 | |
95 | |
95 | |
64 | |
59 |