cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MarkHeydon Frequent Visitor
Frequent Visitor

Duplicates returned with Table.Distinct in M Query

Hi,

I am trying to create a table containing only distinct rows from the union of two existing Power Query tables in Excel.

 

My code (anonymised) is:

let
    SelectColumnsT1 = Table.SelectColumns(T1Data,{"Field1", "Field2", "Field3"}),
    SelectColumnsT2 = Table.SelectColumns(T2Data,{"Field1", "Field2", "Field3"}),
    CombineBoth = Table.Combine({SelectColumnsT1 , SelectColumnsT2 }),
    GetDistinct = Table.Distinct(CombineBoth,{"Field1", "Field2", "Field3"})
in
    GetDistinct

Field1 is an integer and the other fields are strings.

This returns duplicates in the resulting table.  I have checked the individual rows which are duplicates and there are no leading/trailing blanks, and when I check within excel that the fields in the duplicated rows are equal, the result is TRUE.

 

Am I misunderstanding the use of Table.Distinct?

Have I got the syntax wrong?

Is there a bug in this function?

Any other possible things I should look into to try to get to the bottom of this?

 

I would be grateful if anyone can give me any help on this.

 

Regards,

Mark

1 ACCEPTED SOLUTION

Accepted Solutions
MarkHeydon Frequent Visitor
Frequent Visitor

Re: Duplicates returned with Table.Distinct in M Query

Hi @v-yulgu-msft,

Thanks for replying.

I duplicated this post in "Microsoft Power BI Community / Forums / Get Help with Power BI / Desktop" since I think I created this post in the wrong section.

Anyway, after a little more work my conclusion was:

 

<<I have experimented on using an up to date version of Excel (my office uses Excel 2013, my personal laptop has the latest Excel 365).

The problem disappears on my version of Excel, so I think maybe I've uncovered a bug in the old version, which I guess I can't get around.>>

 

Regards,

Mark

View solution in original post

2 REPLIES 2
v-yulgu-msft Super Contributor
Super Contributor

Re: Duplicates returned with Table.Distinct in M Query

Hi @MarkHeydon ,

 

I tested above code on my side, after applying the last step "Table.Distinct", no duplicated rows were shown.

1.PNG

 

In your scenario, after loading T1Data and T2Data into desktop, right click columns, choose "Transform->Clean" to clear invisible characters.

2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MarkHeydon Frequent Visitor
Frequent Visitor

Re: Duplicates returned with Table.Distinct in M Query

Hi @v-yulgu-msft,

Thanks for replying.

I duplicated this post in "Microsoft Power BI Community / Forums / Get Help with Power BI / Desktop" since I think I created this post in the wrong section.

Anyway, after a little more work my conclusion was:

 

<<I have experimented on using an up to date version of Excel (my office uses Excel 2013, my personal laptop has the latest Excel 365).

The problem disappears on my version of Excel, so I think maybe I've uncovered a bug in the old version, which I guess I can't get around.>>

 

Regards,

Mark

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 87 members 1,395 guests
Please welcome our newest community members: