Forum Discussion
raicardi
4 years agoFrequent Visitor
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...
- 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.
MahyarTF
4 years agoMemorable Member
Not sure, why it is not working,
Would you please share your sample PBIX file ?
I check my doing again and it is working
raicardi
4 years agoFrequent Visitor
Let me know if this works?
| Work Date | In Time | Out Time | Overlap | Order | |
| 1/1/2022 | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 1 | |
| 1/1/2022 | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 2 | |
| 1/2/2022 | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 3 | |
| 1/2/2022 | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 4 | |
| 1/3/2022 | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 5 | |
| 1/3/2022 | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 6 | |
| 1/4/2022 | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 7 | |
| 1/5/2022 | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 8 | |
| 1/6/2022 | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 9 | |
| 1/7/2022 | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 10 | |
| 1/7/2022 | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 11 | |
| 1/8/2022 | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 12 | |
| 1/9/2022 | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | OVERLAP | 13 | |
| 1/9/2022 | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | OVERLAP | 14 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 15 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 16 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 17 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 18 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 19 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 20 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 21 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 22 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 23 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 24 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 25 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 26 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 27 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 28 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 29 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 30 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 31 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 32 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 33 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 34 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 35 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 36 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 37 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 38 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 39 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 40 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 41 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 42 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 43 | |
| ######## | 1899-12-30 13:30:00 | 1899-12-30 21:30:00 | '--- | 44 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 21:30:00 | '--- | 45 | |
| ######## | 1899-12-30 15:00:00 | 1899-12-30 21:30:00 | '--- | 46 | |
| ######## | 1899-12-30 07:00:00 | 1899-12-30 15:00:00 | '--- | 47 |
- MahyarTF4 years agoMemorable Member
Hi,
This is my result :