Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Solved! Go to Solution.
Sorry misunderstood your requirement. Hard to test without some data but I think you want to do something like:
#Orders (Buyers OrderValue>50k) =
VAR Customers50k =
FILTER (
VALUES ( 'Orders'[CustomerID] ),
CALCULATE ( SUM( Orders[Order Value EUR]) ) > 50000
)
RETURN
CALCULATE (
DISTINCTCOUNT ( Orders[Sales document] ),
Customers50k
)
Effectively generate the list of CustomerIds and then use it as a filter inside calculate.
Yes and that is incorrect, it will only count the number of customers, (with a total sales amount >50K) not the number of orders.
Sorry misunderstood your requirement. Hard to test without some data but I think you want to do something like:
#Orders (Buyers OrderValue>50k) =
VAR Customers50k =
FILTER (
VALUES ( 'Orders'[CustomerID] ),
CALCULATE ( SUM( Orders[Order Value EUR]) ) > 50000
)
RETURN
CALCULATE (
DISTINCTCOUNT ( Orders[Sales document] ),
Customers50k
)
Effectively generate the list of CustomerIds and then use it as a filter inside calculate.
Could you please tell me why the Calculate is needed in this section : CALCULATE ( SUM( Orders[Order Value EUR]) ) > 50000 ?
I'll try!
CALCULATE does a number of things in DAX. It can add/remove filters but it also forces "context transition". This is where a row context gets moved into the filter context for a calculation.
In the code FILTER iterates over each row in the list of CustomerIds. For each row (customer is) we need to calculate total sales so that rows customer id needs to be moved into the filter context. If it wasn't there you'd get the same value for every customer id.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |