Forum Discussion

Tinus1905's avatar
Tinus1905
Resolver I
2 years ago
Solved

powerbi remove newest time duplicates

Hi,   In PowerBi I have a table with duplicate values. I want to remove the duplicates so the oldest would be deleted.  You can see that Peter worked on 25-10-2023 13:41 with working hours of 08:0...
  • AlienSx's avatar
    AlienSx
    2 years ago

    Tinus1905 open Blad1 in Advanced Editor and replace everything with the following: 

     

    let
        Source = Excel.Workbook(File.Contents("\\dc01\Users\martijnb\Desktop\Hours 2.xlsx"), null, true),
        Blad1_Sheet = Source{[Item="Blad1",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(Blad1_Sheet, [PromoteAllScalars=true]),
        #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date added", type datetime}, {"Workdate", type date}, {"Name", type text}, {"Starttime", type time}, {"endtime", type time}, {"total changed by manager", type time}, {"Namecode", type text}, {"Factory", type text}}),
        g = Table.Group(#"Changed Type", {"Workdate", "Name", "Starttime"}, {{"all", each Table.LastN(Table.Sort(_, "Workdate"), 1)}}),
        combine = Table.Combine(g[all])
    in
        combine