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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Help with duplicates rows

Good morning friends,

My database looks like the one below.
If the "name" column has some duplicates, like for example Luca's 3 rows and Tom's 2, I need to leave only 1 row for each. And the row that I need to leave is the one with the column "situation" = work.

Can you help me?

 

 

NAME

ROLEUnitySituationFired date
JhonfighterTeam 11Fired10/04/2022
LucaapprenticeMigrationFired05/02/2021
LucafighterTeam 12Work 
LucatraineeMigrationFired05/03/2021
JosephdriverTeam 11Fired06/07/2021
TomapprenticeMigrationFired06/08/2021
TomdriverTeam 14Work 
AmandafighterTeam 13Work 
1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

For duplicated rows, you have only 1 row with [Situation]="Work"? Added a custom column to check the condition and filter based on it, paste the M code in Advanced Editor via a blank query to have a look

Vera_33_0-1652316201243.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jY9PC8IwDMW/ivQsNO3mn6sXD0NvAw9jh7LFLcjaEauf3yjIRlHxlJeQ33u8qlJFH7xaqjN1fUQWVaIbFsaI2hNjK9OAhlxbsFbVy0odbo2TqxtHRh+pQVmO1LGL9LJ6Y7DSYJ+YmWNpkBV1CnyRMX+L7MjjL+tssi7CFcde7i3T/UsJWGvYTEgZhr86CLVNqSQlTxrsBufbT1Wz+WP9AA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NAME = _t, ROLE = _t, Unity = _t, Situation = _t, #"Fired date" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom",  (x)=>[a= List.Count( List.Select(Source[NAME],each _=x[NAME])),
b=if a=1 then 1 else if x[Situation] = "Work" then 1 else 0][b]),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = 1))
in
    #"Filtered Rows"

 

View solution in original post

1 REPLY 1
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

For duplicated rows, you have only 1 row with [Situation]="Work"? Added a custom column to check the condition and filter based on it, paste the M code in Advanced Editor via a blank query to have a look

Vera_33_0-1652316201243.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jY9PC8IwDMW/ivQsNO3mn6sXD0NvAw9jh7LFLcjaEauf3yjIRlHxlJeQ33u8qlJFH7xaqjN1fUQWVaIbFsaI2hNjK9OAhlxbsFbVy0odbo2TqxtHRh+pQVmO1LGL9LJ6Y7DSYJ+YmWNpkBV1CnyRMX+L7MjjL+tssi7CFcde7i3T/UsJWGvYTEgZhr86CLVNqSQlTxrsBufbT1Wz+WP9AA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NAME = _t, ROLE = _t, Unity = _t, Situation = _t, #"Fired date" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom",  (x)=>[a= List.Count( List.Select(Source[NAME],each _=x[NAME])),
b=if a=1 then 1 else if x[Situation] = "Work" then 1 else 0][b]),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = 1))
in
    #"Filtered Rows"

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.