I have struggled with this problem: Pivot chart cumulative (running in) distinct count
I am copying it here for convenience...
The idea was to create a cumulative distinct count using this data set:
Month ¦ Drink brand ¦ Drink type
--------------------------------
1 ¦ Abc ¦ Water
1 ¦ Def ¦ Soft
1 ¦ Abc ¦ Water
1 ¦ Ghi ¦ Soft
1 ¦ Xyz ¦ Water
2 ¦ Abc ¦ Water
2 ¦ Abc ¦ Water
2 ¦ Jkl ¦ Soft
2 ¦ Opq ¦ Soft
2 ¦ Abc ¦ Water
And the required chart:
¦
Drink ¦
type ¦ S
cumulative ¦ []
unique ¦ W S W []
count ¦ [] [] [] []
¦_[]_[]___[]_[]_
1 2
Month
I have managed to solve the problem by using PowerPivot and DAX (Data Analysis Expressions) by creating two calculated fields. For "Water" it has been:
=CALCULATE (
DISTINCTCOUNT( Range[Drink brand] ),
FILTER (
ALL ( Range[Month] ),
Range[Month] <= MAX ( Range[Month] )
),
FILTER (
ALL ( Range[Drink type] ),
Range[Drink type] = "Water"
)
)
The problem I have with this solution is its low scallability (the need to create as many new calculated fields as there are "Drink types"). Is there a way to create the same result using DAX with just one calculated field or similar freature? Is is possible to group the result by "Drink type" in just one expression?