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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
D_PBI
Post Partisan
Post Partisan

How to concatenate two column, removing duplicates in DAX?

Hi,
Please view the below table:

table.JPG

 

The above table has two columns Lead and Contributor that I need to concatenate, removing any duplicates but keeping the brackets from the Lead column. The table also shows the Final column. It is this Final column that I need to produce using DAX.
If you look at each row you will see that the values from the Lead column, with their brackets, are always kept. Any names in the Contributor column that are also in the Lead column need to be removed. It is only the non-duplicated names that should be kept, without brackets.

I think the above table explains all clearly.
Hope do I achieve this?
Thanks.

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to do it. Add a custom column with this expression.

 

let
leadlist = Text.Split(Text.Replace(Text.Replace([Lead], "{", ""), "}", ""), ", "),
contriblist = Text.Split([Contributor], ", "),
removedupes = List.Distinct(List.RemoveMatchingItems(contriblist, leadlist)),
result = [Lead] & ", " & Text.Combine(removedupes, ", ")
in
result

 

mahoneypat_0-1641907183528.png

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to do it. Add a custom column with this expression.

 

let
leadlist = Text.Split(Text.Replace(Text.Replace([Lead], "{", ""), "}", ""), ", "),
contriblist = Text.Split([Contributor], ", "),
removedupes = List.Distinct(List.RemoveMatchingItems(contriblist, leadlist)),
result = [Lead] & ", " & Text.Combine(removedupes, ", ")
in
result

 

mahoneypat_0-1641907183528.png

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Can you share this sample file. I am facing problem to concatenate 2 strings without duplicates. Where should I need to write that Query. If am writing in Advanced editor I got error

@mahoneypat  - thanks for the prompt response - it works nicely.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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