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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Distinct count with multiple conditions not working

Hi All,

 

 

I have a table with order data for the past 5 years.The dataset contains order details including order name,customer ID and total price.

 

I am now trying to Distinctcount all the orders(by order name) per customer however I only want to count the ones that have total value above 0.So if a customer has 6 orders in total and only 5 of them have value above 0 then I want it to filter that order out and not count it against the customers order.

 

I tried a couple of Dax syntaxes but none worked,i thought the last one would work but this didnt either.

 

orders per customer excluding 0 values= CALCULATE(
DISTINCTCOUNT(ORDERS_NEW[NAME]),FILTER('ORDERS_NEW'[EMAIL]) AND (ORDERS_NEW[TOTAL_PRICE]>0)
 
 
Has anyone ever come across the same issue.
 
 
Any help will be much appreciated 🙂
 
1 REPLY 1
ibarrau
Super User
Super User

Hi. It looks like your DAX expression syntax is wrong. You might want to try it this way:

orders per customer excluding 0 values = 
CALCULATE(
    DISTINCTCOUNT(ORDERS_NEW[NAME])
    , FILTER( 'ORDERS_NEW', ORDERS_NEW[TOTAL_PRICE] > 0 )
)

FILTER function first argument is the table to iterate checking the condition and the second argument is the condition. 

I hope that works.


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors