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 August 31st. Request your voucher.

Reply
lennox25
Post Patron
Post Patron

Is it possible to remove duplicate numbers from a cell?

Quick question.

 

I have duplicate numbers from two columns merged together in Power Query. Can these duplicate numbers be removed from each cell?

lennox25_0-1719909778612.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @lennox25 

 

Please try this:

= Table.AddColumn(Source, "Custom", each Text.Combine(List.Distinct( Text.Split([Merge]," "))," "))

The result is as follow:

vzhengdxumsft_0-1720514962912.png

 

Best Regards

Zhengdong Xu
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

18 REPLIES 18
Anonymous
Not applicable

Hi @lennox25 

 

Please try this in power query:

= Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(List.Distinct( Text.ToList([Merge]))))

Here I create a set of sample:

vzhengdxumsft_0-1720147170946.png

The result is as follow:

vzhengdxumsft_2-1720147206423.png

 

Best Regards

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

Hi @Anonymous  I have tried this and it fails when it goes past 9 so from 10 onwards it will remove as it thinks is a 1 and just will leave a 0, for say 11 it will remove as there is a 1 there. Any ideas on how to resolve?

Anonymous
Not applicable

Hi @lennox25 

 

How does your data distinguish between 10 and 1,0, is there a space in between.

 

Best Regards

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

Anonymous
Not applicable

Hi @lennox25 

 

Please try this:

= Table.AddColumn(Source, "Custom", each Text.Combine(List.Distinct( Text.Split([Merge]," "))," "))

The result is as follow:

vzhengdxumsft_0-1720514962912.png

 

Best Regards

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

Hi, no there is not, its 1, 10 for example

Thank you @Anonymous   I will give this a try 🙂

Shivu-2000
Super User
Super User

Hi @lennox25 
Can you provide me dummy data and file.

Hi @Shivu-2000 sorry for the delay I had to create a new report removing the senstive info.

 

Link here https://drive.google.com/file/d/1-2imAhCyfFxoR5xH5aSeBs7egEG8ZAbe/view?usp=sharing 

 

Query  -Merge 1 and the Merged Column is where the duplicate numbers need removing from each row 

lennox25_0-1719919893961.png

 

Hi @lennox25 
You have only send me the pbix file not the data.
I need data so that I can open it in power query as when I am trying to open it, it is showing me errors as:

Shivu2000_0-1719987933830.png

 

Hi,

Why is the answer 3 in cell C6?  Shouldn't the answer be 2,0,4,5?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

2045 is the store number

Hi @lennox25 
Do give me the edit access to the sheets as I have to use them in the report.

@Shivu-2000  Done for you

Shivu-2000
Super User
Super User

Hi @lennox25 
You can try any of these method accordingly:
1. Using List.Distinct:

If your data is stored as a list within each cell:

  • Select the column containing the merged data.
  • In the formula bar, enter the following M code:
Table.TransformColumns(
  Source,
  {{"Column Name", value => List.Distinct(value)}}  // Replace "Column Name" with your actual column name
)

2. Splitting, Removing Duplicates, and Joining:

If your data is not stored as a list:

  • Select the column containing the merged data.
  • In the formula bar, enter the following M code:
let
  // Replace "Delimiter" with the character separating your numbers (e.g., comma)
  splitValues = Text.Split(Text.Trim([Column Name]), ",") ,  // Replace "Column Name" with your actual column name
  distinctValues = List.Distinct(splitValues),
  joinedValues = Text.Combine(distinctValues, ",")
in
  Table.TransformColumns(Source, {{[Column Name], joinedValues}})





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

Hi @Shivu-2000 , Is is the 2nd option, but Im not sure how to enter in formula bar, do I need to add a step?

Hi @lennox25 
https://www.youtube.com/watch?v=9dX9PK_KlSA
This might be helpful.

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

@Shivu-2000  thanks for your time. Apologies Im even more confused. This is what I am trying to acheive.

Cell example = 1 2 3 4 5 1 

Looking at the above there are 2 '1's  - I need to remove the additional '1' so that its just '1 2 3 4 5'.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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