Forum Discussion
Calculate overlapping shift start
- 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.
Hi raicardi ,
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.
Refer to:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.