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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
STEVE_WT
Frequent Visitor

Help with a measure DAX

Hi

 

I have a simple transaction table with accounts and product categories.

 

I have a DAX formula already to count the number of customers where they have bought from more than one product category and this works fine.

 

I need another formula similar to this but to only count customers who have bought from more than one product category where a certain product category features e.g. apples.

 

My current formula  :

Plus One Customers = CALCULATE( DISTINCTCOUNT('ALL DATA MART'[Master Account No]), FILTER( VALUES('ALL DATA MART'[Master Account No]), CALCULATE(DISTINCTCOUNT('ALL DATA MART'[Product  Category])) > 1 ) )
 
So I just need this count of customers buying more than one product category but where one of them is 'apples'.
 
Any help would be appreciated.
 
Thanks
1 ACCEPTED SOLUTION
rodrigosan
Responsive Resident
Responsive Resident

Hi, @STEVE_WT , see if this helps you.

Apples Plus One Customers = 
CALCULATE(
    // 1. COUNT: Count the unique accounts that meet the filtering criteria.
    DISTINCTCOUNT('ALL DATA MART'[Master Account No]),
    
    // 2. FILTER CONTEXT: Iterate through every unique Master Account No.
    FILTER(
        VALUES('ALL DATA MART'[Master Account No]),
        
        // --- CHECK A: Must have purchased 'Apples' (Filter 1) ---
        CALCULATE(
            COUNTROWS('ALL DATA MART'),
            'ALL DATA MART'[Product Category] = "Apples"
        ) > 0
        
        // --- CHECK B: Must have purchased MORE THAN ONE category (Filter 2) ---
        && 
        CALCULATE(
            DISTINCTCOUNT('ALL DATA MART'[Product Category])
        ) > 1
    )
)

View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@STEVE_WT 

pls try this

 

Plus One Customers With Apples =
CALCULATE(
DISTINCTCOUNT('ALL DATA MART'[Master Account No]),
FILTER(
VALUES('ALL DATA MART'[Master Account No]),
CALCULATE(DISTINCTCOUNT('ALL DATA MART'[Product Category])) > 1
&&
CALCULATE(
COUNTROWS(
FILTER(
'ALL DATA MART',
'ALL DATA MART'[Product Category] = "apples"
)
)
) > 0
)
)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Ashish_Mathur
Super User
Super User

Hi,

Try these DAX measure pattern

Total = DISTINCTCOUNT('ALL DATA MART'[Product  Category])

Apples count = calulate([Total],'ALL DATA MART'[Product  Category]="Apples")

Measure = calculate(distinctcount('ALL DATA MART'[Master Account No]),filter(VALUES('ALL DATA MART'[Master Account No]),[Total]>1&&[Apples count]>0))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @STEVE_WT ,

Try below Measure.

 

Plus One Customers with Apples =

VAR Customers_MultiCat =

    CALCULATETABLE(

        VALUES('ALL DATA MART'[Master Account No]),

        FILTER(

            VALUES('ALL DATA MART'[Master Account No]),

            CALCULATE(DISTINCTCOUNT('ALL DATA MART'[Product Category])) > 1

        )

    )

 

VAR Customers_Apples =

    CALCULATETABLE(

        VALUES('ALL DATA MART'[Master Account No]),

        'ALL DATA MART'[Product Category] = "apples"

    )

 

RETURN

COUNTROWS(

    INTERSECT(Customers_MultiCat, C

ustomers_Apples)

)

If my response as resolved your issue please mark it as solution and give kudos.

rodrigosan
Responsive Resident
Responsive Resident

Hi, @STEVE_WT , see if this helps you.

Apples Plus One Customers = 
CALCULATE(
    // 1. COUNT: Count the unique accounts that meet the filtering criteria.
    DISTINCTCOUNT('ALL DATA MART'[Master Account No]),
    
    // 2. FILTER CONTEXT: Iterate through every unique Master Account No.
    FILTER(
        VALUES('ALL DATA MART'[Master Account No]),
        
        // --- CHECK A: Must have purchased 'Apples' (Filter 1) ---
        CALCULATE(
            COUNTROWS('ALL DATA MART'),
            'ALL DATA MART'[Product Category] = "Apples"
        ) > 0
        
        // --- CHECK B: Must have purchased MORE THAN ONE category (Filter 2) ---
        && 
        CALCULATE(
            DISTINCTCOUNT('ALL DATA MART'[Product Category])
        ) > 1
    )
)

Perfect. Thanks for breaking down the expanation of the formula also.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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