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

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.

Reply
rrafferty37
Helper I
Helper I

Help with DAX conditional count of orders

Hello,

 

Looking for a bit of help with a measure I can't seem to quite get right.

 

I have a table that has sales order lines.  The Order # is repeated multiple times if there are different SKU's on the order.  My first step is I wanted to sum the amount of units on each order, excluding certain types of units.

 

first measure:  

Order Units = 

CALCULATE(
    SUM('Table 1'[Units Sold]),
    filter('Table 1',OR('Table 1'[Product Type]="Condition 1",'Table 1'[Product Type]="Condition 2")))
 
This does what I expect and seems to be working fine.  My next step is to count the number of orders that have 5 or more units on the order. This is where I am getting hung up.
 
Attempt 1:
Qualified Order Count =

CALCULATE(

    DISTINCTCOUNT('Table 1'[Order]),

    filter('Table 1',[Frames/Suns Sold] >=5 ))

 

I don't recieve any errors, but I do not get a count either, the column is blank. 

I tried passing the Order Units calculation directly into the filter of the above measure as well with no dice. 

 

End Result, I want to be able to see how many orders have 5 or more units (of a certain type) were placed over some period of time.

 

Thanks!

1 ACCEPTED SOLUTION

@Greg_Deckler Thanks Greg, I will be sure to include in the future. I actually found an answer:

 

Qualified Order Count = 

Var units = Order Units

Return

Calculate( 

    DistinctCount('Table 1',

   filter('Table 1', units >=5))

 

Passing the measure as a variable seems to do the trick, althought I am not 100% certain as to why. 

 

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Sample data would be tremendously helpful to replicate and test. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thanks Greg, I will be sure to include in the future. I actually found an answer:

 

Qualified Order Count = 

Var units = Order Units

Return

Calculate( 

    DistinctCount('Table 1',

   filter('Table 1', units >=5))

 

Passing the measure as a variable seems to do the trick, althought I am not 100% certain as to why. 

 

@rrafferty37 ,

 

By the way, you may help accept solution. Your contribution is highly appreciated.

https://www.sqlbi.com/?s=variable

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.