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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
patrick-keen
Frequent Visitor

How to count distinct values in a column?

Hello,

 

How can I count distinct values in one column? For example this column has max. 5 options.

Customer demand,Monthly recurrent revenue,Innovation,Scalability & Flexibility,Efficiency separated by ( , )

 

power-bi.PNG

 

Customer demand,Monthly recurrent revenue,Innovation,Scalability & Flexibility,Efficiency
Customer demand,Monthly recurrent revenue,Innovation,Scalability & Flexibility,Efficiency
Customer demand,Innovation,Efficiency
Innovation,Scalability & Flexibility,Efficiency
Monthly recurrent revenue,Innovation
Monthly recurrent revenue,Innovation
Monthly recurrent revenue,Innovation,Scalability & Flexibility

 

The sum should be:

Customer demand = 3

Monthly recurrent revenue = 5

Innovation = 7

Scalability & Flexibility = 4

Efficiency = 4

 

Kind regards, Patrick 

1 ACCEPTED SOLUTION

Hi patrick-keen,

 

Select all of the columns and click Unpivot before step 1 above, steps left are same with above.

 

Regards,

Jimmy Tao 

View solution in original post

7 REPLIES 7
v-yuta-msft
Community Support
Community Support

Hi patrick-keen ,

 

Please refer to steps below:

1.Click Query Editor-> Split Column by Delimiter->Select Comma as a delimiter. Result is like this:

1.PNG2.PNG 

2.Select column1.1 column1.2 column1.3 column1.4 column1.5-> Click Transform-> Unpivot Columns

3.PNG

5.PNG 

3.After applied&close, create a measure using DAX like this:

Result = COUNTROWS(Table1)

4.PNG 

PBIX file here: https://www.dropbox.com/s/6q124z4g1344796/patrick-keen.pbix?dl=0 

 

Regards,

Jimmy Tao

Hello Jimmy,

 

this works fine for one column, but I have multiple columns with distinct values and than it doesn't work.

Do you have any solutions for this? Thank you in advanced.

 

Kind regards,

Patrick Oude Scholten

Hi patrick-keen,

 

Select all of the columns and click Unpivot before step 1 above, steps left are same with above.

 

Regards,

Jimmy Tao 

Hello Jimmy,

 

I used a part of your solution and added additional querys/tables in Power BI to split them.

 

Thanks for helping me out.

 

Kind regards,

Patrick Oude Scholten 

Hello,

 

please check this post.

jthomson
Solution Sage
Solution Sage


@patrick-keen wrote:

Hello,

 

How can I count distinct values in one column?


Does DISTINCTCOUNT not give you what you want?

Can you give an example?

 

Table values:

Customer demand,Monthly recurrent revenue,Innovation,Scalability & Flexibility,Efficiency
Customer demand,Monthly recurrent revenue,Innovation,Scalability & Flexibility,Efficiency
Customer demand,Innovation,Efficiency
Innovation,Scalability & Flexibility,Efficiency
Monthly recurrent revenue,Innovation
Monthly recurrent revenue,Innovation
Monthly recurrent revenue,Innovation,Scalability & Flexibility

 

for example:

Customer demand the sum should be 3

Monthly recurrent revenue the sum should be 5

Innovation the sum should be 7

Scalability & Flexibility the sum should be 4

Efficiency the sum should be 4

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.