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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
sharpedogs
Advocate II
Advocate II

Removing duplicates - all the values

I'm looking for twist on the remove duplicates

 

my data set is as follows

I want to transform the data using PQ so that anytime My Display Name is Duplicated it removes all the values. In this case i would wnat Chad Shrpe removed from my data set all together. Chad Sharpe may appear any number of times. 

 

Display NameUPN
Chad SharpeChad Sharpe
David JenkinsDavid Jenkins
Chad SharpeCha Sha
Chad Sharpe Ch Sh
Matt Jones Matt Jones

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

I believe I saw @ImkeF  or @edhans answer a similar question to this recently.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

edhans
Super User
Super User

This M code will do what you want.

It turns this:

2020-04-20 07_40_01-Untitled - Power Query Editor.png

into this

2020-04-20 07_40_12-Untitled - Power Query Editor.png

 

What it does is creates a table that counts how many times a name appears, then a nested table of all records. I then filter out everything that isn't a count of 1, and expand the nested table again.

 

1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs5ITFEIzkgsKkhV0kHhxepEK7kklmWmKHil5mVn5hUD5VH5IBUY+kEcrDJANljcN7GkRMErPy+1+NACoASCqxQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Display Name" = _t, UPN = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Display Name", type text}, {"UPN", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Display Name"}, {{"Count", each Table.RowCount(_), type number}, {"All Rows", each _, type table [Display Name=text, UPN=text]}}),
    #"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Count] = 1)),
    #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"All Rows"}),
    #"Expanded All Rows" = Table.ExpandTableColumn(#"Removed Other Columns", "All Rows", {"Display Name", "UPN"}, {"Display Name", "UPN"})
in
    #"Expanded All Rows"

 

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

This M code will do what you want.

It turns this:

2020-04-20 07_40_01-Untitled - Power Query Editor.png

into this

2020-04-20 07_40_12-Untitled - Power Query Editor.png

 

What it does is creates a table that counts how many times a name appears, then a nested table of all records. I then filter out everything that isn't a count of 1, and expand the nested table again.

 

1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs5ITFEIzkgsKkhV0kHhxepEK7kklmWmKHil5mVn5hUD5VH5IBUY+kEcrDJANljcN7GkRMErPy+1+NACoASCqxQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Display Name" = _t, UPN = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Display Name", type text}, {"UPN", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Display Name"}, {{"Count", each Table.RowCount(_), type number}, {"All Rows", each _, type table [Display Name=text, UPN=text]}}),
    #"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Count] = 1)),
    #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"All Rows"}),
    #"Expanded All Rows" = Table.ExpandTableColumn(#"Removed Other Columns", "All Rows", {"Display Name", "UPN"}, {"Display Name", "UPN"})
in
    #"Expanded All Rows"

 

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Greg_Deckler
Community Champion
Community Champion

I believe I saw @ImkeF  or @edhans answer a similar question to this recently.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Kudoed Authors