Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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'[Order]),FILTER(ALLSELECTED('Table'),'Table'[Order]<max('Table'[Order]))).
This works but I would like to have it counted per customer without having to filter them. (Expected results: 0-1-2-2-0-1-0-1). In addition, I'd like to know how to do the same thing with a calculated column, since using the formula as is returns only 1 number.
Thx,
Joery
Solved! Go to Solution.
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
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
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
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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 43 | |
| 43 | |
| 38 | |
| 18 | |
| 15 |
| User | Count |
|---|---|
| 67 | |
| 63 | |
| 30 | |
| 30 | |
| 23 |