Forum Discussion
joerykeizer
7 years agoHelper II
Cumulative distinct count
Hi all, I have a table with order, date and customer and I would like to count the number of cumulative orders per customer. Currently I have: Measure = CALCULATE(DISTINCTCOUNT('Table'[Ord...
- 7 years ago
Hi joerykeizer
You may try to create a measure or column as below:
Measure = CALCULATE ( DISTINCTCOUNT ( Table1[Order] ), FILTER ( ALLEXCEPT ( Table1, Table1[Customer] ), Table1[Order] < MAX ( Table1[Order] ) ) ) + 0Column = CALCULATE ( DISTINCTCOUNT ( Table1[Order] ), FILTER ( Table1, Table1[Customer] = EARLIER ( Table1[Customer] ) && Table1[Order] < EARLIER ( Table1[Order] ) ) ) + 0Regards,
Cherie
v-cherch-msft
7 years agoMicrosoft Employee
Hi joerykeizer
You may try to create a measure or column as below:
Measure =
CALCULATE (
DISTINCTCOUNT ( Table1[Order] ),
FILTER (
ALLEXCEPT ( Table1, Table1[Customer] ),
Table1[Order] < MAX ( Table1[Order] )
)
)
+ 0Column =
CALCULATE (
DISTINCTCOUNT ( Table1[Order] ),
FILTER (
Table1,
Table1[Customer] = EARLIER ( Table1[Customer] )
&& Table1[Order] < EARLIER ( Table1[Order] )
)
)
+ 0Regards,
Cherie
joerykeizer
7 years agoHelper II
Thank you! There is one issue though.
This works perfectly in my test-dataset but calculating the column is too heavy in the actual one. Dataset is currently ~155k rows. Is there any way to do this more efficiently?
Regards,
Joery
- v-cherch-msft7 years agoMicrosoft Employee
Hi joerykeizer
You may also try to make a query with M language in Advanced Editor in Query Editor. It seems a more complicated way.
Regards,
Cherie