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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Need help with count no of customer

Hello,

 

Can you please help me writing following DAX formula:

 

I want to calculate  no of customer who have both product A and B only as Measure. Can you please advise me on it. Thanks!

Customer IDProduct Type
1A
1A
1B
2A
2B
2B
3A
4B
5B
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try like

countx(filter(summarize(Table, Table[Customer], "_1", calculate(distinctcount(Table[Product Type]), filter(Table,[Product Type] in {"A", "B"}))), [_1]=2),[Customer])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

v-luwang-msft
Community Support
Community Support

HI  @Anonymous ,

Try the below measure:

test =
VAR test1 =
    IF (
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Product Type] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Customer ID] = MAX ( 'Table'[Customer ID] ) )
        ) > 1,
        1,
        0
    )
RETURN
    test1
sumcount = CALCULATE(DISTINCTCOUNT('Table'[Customer ID]),FILTER('Table',[test]>0))

And final get:

vluwangmsft_0-1628142753198.png

 

Wish it is helpful for you!

 

Best Regards

Lucien

View solution in original post

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

HI  @Anonymous ,

Try the below measure:

test =
VAR test1 =
    IF (
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Product Type] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Customer ID] = MAX ( 'Table'[Customer ID] ) )
        ) > 1,
        1,
        0
    )
RETURN
    test1
sumcount = CALCULATE(DISTINCTCOUNT('Table'[Customer ID]),FILTER('Table',[test]>0))

And final get:

vluwangmsft_0-1628142753198.png

 

Wish it is helpful for you!

 

Best Regards

Lucien

amitchandak
Super User
Super User

@Anonymous , Try like

countx(filter(summarize(Table, Table[Customer], "_1", calculate(distinctcount(Table[Product Type]), filter(Table,[Product Type] in {"A", "B"}))), [_1]=2),[Customer])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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