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
RJMonteza
Regular Visitor

Please help to build DAX to count a category with an exception for the certain period.

I have different Order Types per Period:

1. Entry

2. Revision

3. CleanUp

4. Quote Entry

5. Quote Revision

 

What I need is to count how many Entry and Revision per period. I have rows 1 to 12 for the period.

 

I was only able to count all but I'm struggling on how to apply EXCEPT type 3 to 5. Please help me build the complete DAX:

 

SUMX(VALUES('CRM Data (2)'[PD Completed]),CALCULATE(COUNTROWS('CRM Data (2)')))
 
Thanks!
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

Try this: 

SUMX(

    VALUES('CRM Data (2)'[PD Completed]),

    CALCULATE(

        COUNTROWS('CRM Data (2)')

    ),

    'CRM Data (2)'[Order Types] IN {"Entry", "Revision"}

)

View solution in original post

3 REPLIES 3
RJMonteza
Regular Visitor

Thank you! That's what I'm looking for. I thought I need to put an "Except" before this  'CRM Data (2)'[Order Types] IN {"Entry", "Revision"}, that's where my previous formula isn't working. So it can be as simple as that. Awesome!

the except is actually a NOT logic, the code below shall also work, 

 

SUMX(

    VALUES('CRM Data (2)'[PD Completed]),

    CALCULATE(

        COUNTROWS('CRM Data (2)')

    ),

    NOT 'CRM Data (2)'[Order Types] IN {"CleanUp", "Quote Entry", "Quote Revision"}

)

 

In cases when the list you want to exclude is the longer half, you can try this way. 

FreemanZ
Super User
Super User

Try this: 

SUMX(

    VALUES('CRM Data (2)'[PD Completed]),

    CALCULATE(

        COUNTROWS('CRM Data (2)')

    ),

    'CRM Data (2)'[Order Types] IN {"Entry", "Revision"}

)

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