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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Not applicable

DistinctCount IF?

Hi All,


I'm new to Power BI (and DAX) coming from Tableau.


I've got a question regarding the DiscountCount function.


I need to calculate a percentage of orders that include a certain item. The way my data is structured is line items on every order for the last year. (Example: If one order has three items on it, three lines are returned for that order each line with a specific item).


I'd like to create a measure that give me the sum of a distinct count of order numbers but only if they include a certain item number. I can't use the filter function because I'd need to compare the afore mentioned measure to a count of all distinct orders.


This seems like something that should be very doable, I'm just can't wrap my head around it yet.




PS - Does anyone have any good resources (perferably books) that can get me into the swing of using DAX and Power BI?

Resident Rockstar
Resident Rockstar

    DISTINCTCOUNT( FactOrder[OrderNumber] )
    ,FactOrder[Line Item] = <certein item number>

View solution in original post

Resident Rockstar
Resident Rockstar

    DISTINCTCOUNT( FactOrder[OrderNumber] )
    ,FactOrder[Line Item] = <certein item number>

@greggyb  @KHorseman  I am trying to use your formula, but i am not sure where I am doing a mistake 


want to calculate distinct job number on gloss pack option or body colour option 



Here is the error 




@greggyb  Can you please tell me where i am doing wrong, I tried to use your formula 




Not applicable

Worked perfectly! Thank you so much!

If you want to understand the reason behind that answer, check this out:


Actually the title of that blog post is slightly misleading; CALCULATE is a supercharged WHATEVERIF. COUNTIF, SUMIF, DIVIDEIF, etc. depending on what kind of expression you feed into it. That whole blog is a fantastic resource for learning DAX, and they've got a great book as well.

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Not applicable

Thank for the resource, I really appreciate it!

Helpful resources

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors