Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
dgdgdg122db
Helper II
Helper II

variables virtual tables

Hello there,
I am trying to count the number of orders for the customers who has the total order value above 50K. My DAX looks like below, I just do not how to continue. How to pass the "50orders" to my calculation.
Can someone please help.
 
 
 
#Orders (Buyers OrderValue>50k) =
var totalorders=
SUMMARIZE(Orders,
'Orders'[CustomerID],
"TotalSales",SUM(Orders[Order Value EUR]),
"50orders",DISTINCTCOUNT(Orders[Sales document]))
var order50K= FILTER(totalorders,[TotalSales]>50000)
return


1 ACCEPTED 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.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

6 REPLIES 6
bcdobbs
Community Champion
Community Champion

Have you tried COUNTROWS ( order50K )



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

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.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

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.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Thank you very much @bcdobbs 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors