cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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

v-yulgu-msft
Microsoft
Microsoft

Hi @Anonymous ,

 

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.

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors