Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Remove Duplicates not working and M code for counting duplicates in a new column is required

Hello All,

 

I am trying to remove duplicates from Serial Number column but still few are left . Why remove dublicates are not working please find below the M code :-

 

#"Sorted Rows" = Table.Sort(#"Filtered Rows5",{{"Serial_Number", Order.Ascending}}),
#"Buffer Table" = Table.Buffer(#"Sorted Rows"),
#"Removed Duplicates" = Table.Distinct(#"Buffer Table", {"Serial_Number"}),

 

 

before this still i have to remove :

#"Filtered Rows5" = Table.SelectRows(#"Filtered Rows2", each [Serial_Number] <> "XXXX" and [Serial_Number] <> "DELETED" and [Serial_Number] <> "V0147" and [Serial_Number] <> "Delete" and [Serial_Number] <> "DUMMY" and [Serial_Number] <> "DUPLICATE" and [Serial_Number] <> "ERROR" and [Serial_Number] <> "FB0383" and [Serial_Number] <> "DUPLICIDADE" and [Serial_Number] <> "N/A" and [Serial_Number] <> "ABC" and [Serial_Number] <> "ABCD" and [Serial_Number] <> "xyz Regions" and [Serial_Number] <> "C" and [Serial_Number] <> "A" and [Serial_Number] <> "UNKNOWN" and [Serial_Number] <> "NA" and [Serial_Number] <> "N A" and [Serial_Number] <> "X4FL62J87395"),

 

Why power Query is passing these through ?What to do and in order to find these i worte a DAX code to check if still Duplicates are avaialble - 

Dublicate = CALCULATE(COUNT('Product Group'[Serial_Number]),FILTER('Product Group','Product Group'[Serial_Number] =EARLIER('Product Group'[Serial_Number])))
 
after checking this i have to come back to Query editor and filter specific serial numbers .
 
Please suggest an M code so that it can count those dupliactes as a seperate column and later on filter it .
 
 

 

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    I try to reproduce it.

    And my result is right.

    If possible, please provide some sample data and expected result.

     

    Best Regards,

    Stephen Tao

     

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