Forum Discussion

fedeleu's avatar
fedeleu
Frequent Visitor
4 years ago
Solved

Problems with Table.Distinct

Hi!

I have the following code

let

    Origen = Table.Combine({Unico2020, Unico2021}),

    #"Filas filtradas" = Table.SelectRows(Origen, each ([Titolare] = "Empresa")),

    #"Tipo cambiado" = Table.TransformColumnTypes(#"Filas filtradas",{{"Inizio Coll", type date}}),

    #"Columna condicional agregada" = Table.AddColumn(#"Tipo cambiado", "orden_estado", each if [Stato] = "CONSUNTIVATO" then 1 else if [Stato] = "VERIFICA DOCUMENTALE" then 2 else 3),

    #"Filas ordenadas" = Table.Sort(#"Columna condicional agregada",{{"Inizio Coll", Order.Ascending}, {"orden_estado", Order.Ascending}, {"Avviso", Order.Ascending}}),

    #"Duplicados quitados" = Table.Distinct(#"Filas ordenadas", {"Fornitore"})

in

    #"Duplicados quitados"

 

I expected to keep the first unique value of the column "Fornitore", since I previously ordered by "Inizio Coll", "orden_estado" and "Avviso", which are the fields that give me a priority in the data to keep.

However I have come across records that do not meet that criteria.

 

Can someone tell me that I am doing wrong that I do not have the first record that meets my order criteria?

 

Thanks,

Federico

  • Hi fedeleu,

     

    Can you try adding Table.Buffer(PreviousStep), immediately before the Table.Distinct step?

    Let me know if this improves the results for you.

     

    Regards,

    Kim 

3 Replies

  • KNP's avatar
    KNP
    Icon for Super User rankSuper User

    Hi fedeleu,

     

    Can you try adding Table.Buffer(PreviousStep), immediately before the Table.Distinct step?

    Let me know if this improves the results for you.

     

    Regards,

    Kim