Forum Discussion

raicardi's avatar
raicardi
Frequent Visitor
4 years ago
Solved

Calculate overlapping shift start

I am relatively new to BI, more used to excel, and am having a difficult time showing overlapping shift. Formula and screenshot of excel below.  F(F3=F2, IF(H3=I2, "follow", IF(H3<I2, "OVERLAP", "Af...
  • Bubble4502's avatar
    4 years ago

    Hi raicardi ,

     

    Approve with MahyarTF .

    Here is my solution:

    You can create index column in Power Query:

    Here is the M code:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJS0lEytLC01DU00jU2UDAwtzIwACJUUUNTqGisDi6NhsZWxpgajQyhohCNRuTaiE0jUTYak2sjNo2EbIwFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Work Date" = _t, #"In Time" = _t, #"Out Time" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Work Date", type date}, {"In Time", type datetime}, {"Out Time", type datetime}}),
        #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type)
    in
        #"Added Index"

    Then create and apply the measure:

    Measure = 
    var _a = MAX('Table'[Index])
    var _b = FILTER(ALL('Table'),[Index]=_a-1)
    return IF( MAXX(_b,'Table'[Work Date])=MAX('Table'[Work Date]),
    SWITCH(TRUE(),
    MAXX(_b,[Out Time])=MAX('Table'[In Time]),"follow",
    MAXX(_b,[Out Time])>MAX('Table'[In Time]),"OVERLAP",
    "After"),"---")

    Output:

    Kind Regards,

    Bubble

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