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
RustyNails
Helper III
Helper III

DAX measure to Sum if all category values exist

I have two categories: Apples and Oranges. I want to Sum the product's Qty if and only if BOTH apples and oranges have a Qty count for that particular product. Here's an example

 

 

In the example above, only Item 1 and Item 4 have both Apples and Oranges Qty so they are the only valid ones that I want to count. I want to exclude Item 2 and 3 because they have one category each (and not both).

 

How do I even begin with the DAX here? To take a step further, the Category field is dynamic. I could have Apples, Oranges and Bananas and items should have all three Qty's to satisfy my criteria. Any help is greatly appreciated.

1 ACCEPTED SOLUTION

@RustyNails

 

Please see attached file as well

 

dxm.png


Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@RustyNails

 

try this measure

 

Measure =
VAR AllCat =
    COUNTROWS ( ALL ( Table1[Category] ) )
RETURN
    CALCULATE (
        SUM ( Table1[Qty] ),
        FILTER (
            VALUES ( Table1[Product] ),
            CALCULATE ( COUNTROWS ( VALUES ( Table1[Category] ) ) ) = Allcat
        )
    )

Regards
Zubair

Please try my custom visuals

@RustyNails

 

Please see attached file as well

 

dxm.png


Regards
Zubair

Please try my custom visuals

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.