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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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

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
        )
    )

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors