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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
Employee

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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