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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Help with Distinct Count (of orders below or above a certain value)

Hello Community, 

 

I created the two measures below, and thought they were working fine.   In reviewing my data, I noticed something wrong with how I've done this that I'm sure is easy to fix...just not sure how.    The problem is that Orders can have multiple lines, and these measures are not aggregating the total order value of all the lines  - see explanation below.  

 

I need to sum the value of orders in two distinct groups, and I need to count the "distinct" number of orders in each of those groups (in other words, count the number of distinct Order #'s within each group).    Orders that have a value of $75,000 or more.   Orders less than $75000.    

 

Count of More Than 75k = CALCULATE(DISTINCTCOUNT('Flu Shipped'[Order]),'Flu Shipped'[Net Price]>=75000)
 
Count of Less Than 75k = CALCULATE(DISTINCTCOUNT('Flu Shipped'[Order]),'Flu Shipped'[Net Price]<75000)
 
These measure I thought were working fine, until I realized that they were counting the value of each line
in an order, rather than aggregate total of the order.
 
Example: Order # 2367A might have 4 lines to it. If I put my measures in table, it was counting
Order 2367A twice: Once for lines 1,3, and 4 because they totaled < 75k. And once for line 2 because
it totaled over 75k. The count I need for this order would be "1" because in aggreagate, the total
order value is over 75k.
 
Order # Line $ Value
2367A 1 20,000
2367A 2 80,000
2367A 3 10,000
2367A 4 15,000
 
Thanks in advance for any help!
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Try like

 Count of More Than 75k = countX(filter(summarize('Flu Shipped','Flu Shipped'[Order],"_sum",sum('Flu Shipped'[Net Price]))[_sum]>=75000),[Order])
 Count of less Than 75k = countX(filter(summarize('Flu Shipped','Flu Shipped'[Order],"_sum",sum('Flu Shipped'[Net Price]))[_sum]<75000),[Order])
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

Try like

 Count of More Than 75k = countX(filter(summarize('Flu Shipped','Flu Shipped'[Order],"_sum",sum('Flu Shipped'[Net Price]))[_sum]>=75000),[Order])
 Count of less Than 75k = countX(filter(summarize('Flu Shipped','Flu Shipped'[Order],"_sum",sum('Flu Shipped'[Net Price]))[_sum]<75000),[Order])
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors