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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
        )
    )

@RustyNails

 

Please see attached file as well

 

dxm.png

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.