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
bml123
Post Patron
Post Patron

Distinct count by category

Hi,

 

I have a Clients table with client details

Clients IdNameDOBCountry
1  Uk
2  USA
3  UK

 

and another products table 

Product IdProduct TypeClient Id
100P11
101P21
102P12

 

I want to get distinct country count by product type

Product TypeCount of distinct country
P12
P21

 

How do I achieve that?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @bml123 ,

 

Please check this measure.

Measure =
VAR ids =
    CALCULATETABLE (
        VALUES ( products[Client Id] ),
        FILTER (
            ALLSELECTED ( products ),
            products[Product Type] = SELECTEDVALUE ( products[Product Type] )
        )
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Clients[Country] ),
        FILTER ( ALLSELECTED ( Clients ), Clients[Clients Id] IN ids )
    )

vjaywmsft_0-1652773380022.png

 

Best Regards,

Jay

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @bml123 ,

 

Please check this measure.

Measure =
VAR ids =
    CALCULATETABLE (
        VALUES ( products[Client Id] ),
        FILTER (
            ALLSELECTED ( products ),
            products[Product Type] = SELECTEDVALUE ( products[Product Type] )
        )
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Clients[Country] ),
        FILTER ( ALLSELECTED ( Clients ), Clients[Clients Id] IN ids )
    )

vjaywmsft_0-1652773380022.png

 

Best Regards,

Jay

PhilipTreacy
Super User
Super User

Hi @bml123 

 

Download example PBIX file

 

Try this

 

Distinct Country Count by Product Type = CALCULATE(DISTINCTCOUNT([Client Id]), FILTER('Data', 'Data'[Product Type] = SELECTEDVALUE('Data'[Product Type])))

 

 

dc.png

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


jsaunders_zero9
Responsive Resident
Responsive Resident

Hi @bml123 

When you say table do you need this represented in a visual or data table?

Thank you

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