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
s_schwantes
Frequent Visitor

How to find all distinct employee names in an entire table (all columns and rows)

My source data in Excel had roughly 26 columns with EE data. Unfortunately, each column could contain multiple names per cell value. I created a query in PBI to split out to ~ 75 columns with one EE name per column. Next I'm looking to find the following:


1) all distinct names in the entire table

2) count of all the distinct names (how many times does a distinct name appear irregardless of row or column)

3) count of all the rows a distint name appears in & all the columns a distinct name appears in - along with a view of what the those column headers are for each distinct name, i.e., list each distinct name and then each column that name appears in...

 

Any and all suggestions on best approach are wecome. Sorry I can't post any sample data. Hopefully this will suffice as a general baseline . . . 

Thanks!

Steve

6 REPLIES 6
v-xiaotang
Community Support
Community Support

Hi @s_schwantes 

Have you solved this problem? If yes, could you kindly accept the answer helpful as the solution (or kindly share your solution ). so the others can find it more quickly.
really appreciate!
Any question, please let me know. Looking forward to receiving your reply.


Best Regards,
Community Support Team _Tang

v-xiaotang
Community Support
Community Support

Hi @s_schwantes 

I have a method, but if you have a lot of columns, it will be a bit cumbersome, you need to keep copying and pasting column name.

1) all distinct names in the entire table

you can create a new table, the new table includes all values, then put it into table visual, the table visual will display distinct values automatically,(I suggest this method for the second step)

Table = UNION(SUMMARIZECOLUMNS(mytablename[Column1]),SUMMARIZECOLUMNS(mytablename[Column2]),SUMMARIZECOLUMNS(mytablename[Column3]),SUMMARIZECOLUMNS(mytablename[Column4]))

 or you can get distinc table directly by adding DISTINCT(),

Table = DISTINCT(UNION(SUMMARIZECOLUMNS(mytablename[Column1]),SUMMARIZECOLUMNS(mytablename[Column2]),SUMMARIZECOLUMNS(mytablename[Column3]),SUMMARIZECOLUMNS(mytablename[Column4])))

result of my created sample,

vxiaotang_0-1629098468282.png

2) count of all the distinct names (how many times does a distinct name appear irregardless of row or column)

The COUNT function counts the number of cells in a column that contain non-blank values.
Syntax
COUNT(<column>)  

actually, count function acts on a column, not multiple columns, so we need to summarize multiple columns into one column.

based on the first step, create the measure

Count = COUNT('Table'[Column1])

result

vxiaotang_1-1629099611127.png

3) count of all the rows a distint name appears in & all the columns a distinct name appears in - along with a view of what the those column headers are for each distinct name, i.e., list each distinct name and then each column that name appears in...

 

count of all the rows a distint name appears in, this seems not very possible in DAX...

count of all the columns a distinct name appears in, this is possible but a little troublesome, you need to write all your column names in your measure...

 

 

Best Regards,

Community Support Team _Tang

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

s_schwantes
Frequent Visitor

Actually, my table has more than just columns with EE names so curious how do I isolate just EE names?

selimovd
Super User
Super User

Hey @s_schwantes ,

 

in DAX you can count the distinct values:

Amount distinct names =
COUNTROWS(
    DISTINCT( myTable[Name] )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

Thanks Denis - trying your suggestion and will circle back asap.

 

Okay, this works for one column; e.g., = countrows(distinct('mytablename'[column_1])) ... how do I make this work across all the columns of interest in my table? 

Thanks!

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.