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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.