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
catcabs
New Member

Group By Aggregate > Remove Duplicates in returned field

Hi Team!

 

I used Group By > Advanced > Add Aggregates to group my table by 3 columns using ID as the unique identifier. I've successfully done this, but now my results show duplicates. Can you please please help me remove the duplicates per field?

 

E.g. "SAP, SAP, SAP" should only show "SAP" and "Modern ERP (SAP), Finance (SAP), Finance SAP)" should only show "Modern ERP (SAP), Finance SAP).

 

Thank you so much!!!

 

catcabs_0-1683120856563.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @catcabs ,

 

Please click "Advanced Editor" to copy and paste the following code, check the steps in the right step bar.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKtY38XD0c1TSUfLNT0ktylNwDQpQ0Ah2DNAECgEppVgd0hTpwOjkNCDCokXHLTMvMS85FQsHu+k6SFgpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [UCSg = _t, #"DC G" = _t, #"PTG G" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"UCSg", type text}, {"DC G", type text}, {"PTG G", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Distinct(Text.Split([PTG G],","))),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Added Custom1" = Table.AddColumn(#"Extracted Values", "Custom.1", each List.Distinct(Text.Split([UCSg],","))),
    #"Extracted Values1" = Table.TransformColumns(#"Added Custom1", {"Custom.1", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Added Custom2" = Table.AddColumn(#"Extracted Values1", "Custom.2", each List.Distinct(Text.Split([DC G],","))),
    #"Extracted Values2" = Table.TransformColumns(#"Added Custom2", {"Custom.2", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Renamed Columns" = Table.RenameColumns(#"Extracted Values2",{{"Custom.1", "UCSg1"}, {"Custom.2", "DC G1"}, {"Custom", "PTG G1"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"UCSg", "DC G", "PTG G", "UCSg1", "DC G1", "PTG G1"}),
    #"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"UCSg", "DC G", "PTG G"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"UCSg1", "UCSg"}, {"DC G1", "DC G"}, {"PTG G1", "PTG G"}})
in
    #"Renamed Columns1"

vtangjiemsft_0-1683257420520.png

Best Regards,

Neeko Tang

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

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @catcabs ,

 

Please click "Advanced Editor" to copy and paste the following code, check the steps in the right step bar.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKtY38XD0c1TSUfLNT0ktylNwDQpQ0Ah2DNAECgEppVgd0hTpwOjkNCDCokXHLTMvMS85FQsHu+k6SFgpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [UCSg = _t, #"DC G" = _t, #"PTG G" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"UCSg", type text}, {"DC G", type text}, {"PTG G", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Distinct(Text.Split([PTG G],","))),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Added Custom1" = Table.AddColumn(#"Extracted Values", "Custom.1", each List.Distinct(Text.Split([UCSg],","))),
    #"Extracted Values1" = Table.TransformColumns(#"Added Custom1", {"Custom.1", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Added Custom2" = Table.AddColumn(#"Extracted Values1", "Custom.2", each List.Distinct(Text.Split([DC G],","))),
    #"Extracted Values2" = Table.TransformColumns(#"Added Custom2", {"Custom.2", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Renamed Columns" = Table.RenameColumns(#"Extracted Values2",{{"Custom.1", "UCSg1"}, {"Custom.2", "DC G1"}, {"Custom", "PTG G1"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"UCSg", "DC G", "PTG G", "UCSg1", "DC G1", "PTG G1"}),
    #"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"UCSg", "DC G", "PTG G"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"UCSg1", "UCSg"}, {"DC G1", "DC G"}, {"PTG G1", "PTG G"}})
in
    #"Renamed Columns1"

vtangjiemsft_0-1683257420520.png

Best Regards,

Neeko Tang

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

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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