Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate present and next value

Hey guys 🙂 I want to calculate break between starting date and ending date by only if name are equals.   ( 10:16:30  -  10:15:30  = 00:01:00)    e.g. Starting date      |    Ending date      | ...
  • Anonymous's avatar
    Anonymous
    6 years ago

    try with this.

     

     

     

    let
        rr = Table.Group(yourTab, {"Group"}, {{"Breaks", each brksGroup(_), type table}}),
        tbe = Table.ExpandTableColumn(rr, "Breaks", {"List.Breaks"}, {"List.Breaks"})
    in
        tbe

     

     

     

     

    where, brkGroup is the following code.

     

     

     

     

    let
        breakTab=(tab as table) =>
    let
     tabSorted=Table.Sort(tab,{"Start"}),
     breakList=List.Accumulate(List.Numbers(1,Table.RowCount(tabSorted)-1), {},(s,c)=>s&{tabSorted[Start]{c}-tabSorted[End]{c-1}}) 
    in
    Table.FromColumns({breakList},{"List.Breaks"})
    in
        breakTab

     

     

     

     

    PS

    the code intends to produce a break list, in case of multiple interruptions