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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sajtx725
Regular Visitor

Count Distinct Across Multiple Columns in PowerBI

Hi,

 

I'm trying to do a distinct count across multiple rows in Power Bi.  But I noticed that the DISTINCTCOUNT() function in power bi only takes one column. 

 

For example, let's say I have multiple columns in my table for product, category, and subcategory.  I want to do a distinct count of all the combinations across these three columns.  How can I do that? 

 

I appreciate any support.  Thanks.

1 ACCEPTED SOLUTION
v-pnaroju-msft
Community Support
Community Support

Thank you, @Ritaf1983 , @lmolus , and @lbendlin , for your responses.


Hi sajtx725,

We sincerely appreciate your inquiry through the Microsoft Fabric Community Forum.

In addition to the responses provided by @Ritaf1983 , @lbendlin , and @lmolus , kindly find attached a sample PBIX file and a screenshot for your reference. To obtain the distinct count of combinations across multiple columns such as Product, Category, and Subcategory, we have created a calculated column by concatenating these fields using the "&" operator, and then applied a DISTINCTCOUNT measure on that column.

vpnarojumsft_0-1753074567180.png

We hope that the information provided will assist in resolving your issue. Should you have any further questions or require additional assistance, please feel free to reach out to the Microsoft Fabric Community.

Thank you.

View solution in original post

6 REPLIES 6
v-pnaroju-msft
Community Support
Community Support

Thank you, @Ritaf1983 , @lmolus , and @lbendlin , for your responses.


Hi sajtx725,

We sincerely appreciate your inquiry through the Microsoft Fabric Community Forum.

In addition to the responses provided by @Ritaf1983 , @lbendlin , and @lmolus , kindly find attached a sample PBIX file and a screenshot for your reference. To obtain the distinct count of combinations across multiple columns such as Product, Category, and Subcategory, we have created a calculated column by concatenating these fields using the "&" operator, and then applied a DISTINCTCOUNT measure on that column.

vpnarojumsft_0-1753074567180.png

We hope that the information provided will assist in resolving your issue. Should you have any further questions or require additional assistance, please feel free to reach out to the Microsoft Fabric Community.

Thank you.

This worked for me, Thanks.

lbendlin
Super User
Super User

 I want to do a distinct count of all the combinations across these three columns

SUMMARIZE these columns and then COUNTROWS the resulting table variable.

Interesting take on this.  I appreciate it.

Ritaf1983
Super User
Super User

Hi @sajtx725 
If you need to count unique values across 3 columns :

You need to union the columns .
It can be done virtually inside DAX calculation 
Like :

DistinctValuesAcross3Columns =

COUNTROWS (

    DISTINCT (

        UNION (

            SELECTCOLUMNS('Table', "Value", 'Table'[Column 1]),

            SELECTCOLUMNS('Table', "Value", 'Table'[Column 2]),

            SELECTCOLUMNS('Table', "Value", 'Table'[column 3])

        )

    )

)
Ritaf1983_0-1752991261233.png

If the goal is to count unique combibnations than you can use Summirize :

DistinctValuesCombinations =

COUNTROWS (

    SUMMARIZE('Table','Table'[Column 1],'Table'[Column 2],'Table'[Column 3])
Ritaf1983_0-1753012670456.png

 


The pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi,

SUMMARIZE provides a unique table, so there is no need to use DISTINCT .right before.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.