Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
bertferschner
Frequent Visitor

Pls help with M Code/DAX: Identifying Overlaps in Work Time Entries

My goal is to identify overlaps in timesheet entries, but I'm struggling to find the correct logic structure for a solution. I prefer to work mostly in Power Query to reduce measures, but also realize it could also be more effective/simpler with DAX. For each Resource ID, need to check if the Work # schedules overlap. I do not need to know if separate Resource IDs schedules overlap.

 

Resource IDWork #Monday Schedule BeginMonday Schedule EndMonday Schedule
7701K1   
7701K2   
7701K39:00:0011:00:0009:00a - 11:00a
7701K47:00:009:00:0007:00a - 09:00a
7701K510:00:0017:00:0010:00a - 05:00p
7701K615:00:0016:00:0003:00p - 04:00p
7703K1   
7703Holiday6:00:0016:00:0006:00a - 04:00p
7703SAFETY TRAINING   
7780K17:00:0011:00:007:00a - 11:00a
7780K210:00:0016:00:0010:00a - 04:00p
7781K17:00:0016:00:0007:00a - 04:00p
1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZBRC4IwEMe/yrBXg01zs96KrCTyQYUI6UF0VBQuih769t0s3bQJ23H873532z/LLMvWztHOrJg/xetRcBQuQdqLxxWNINmJqszfKCnOvHzdOFrw06Uy6EFV/qv1YMYwgdJWBtReveIMVlwI0xnGcCAjpE2xVHM0RrWWd6AJBNZ2KhyzH/OFO4wnx2O1SfG1WlMeJPcORWXdU61U7XJls6QmOuUOGiErG3G7gH2QUeNM2rzkb2YyXwXpAaXxPIzCaG1Y4ONmNTP5yUx2fhmnZw01WKM/yCeGTdovWA86fgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t]),
    Custom1 = Table.PromoteHeaders(Table.Skip(Source)),
    #"Changed Type" = Table.TransformColumnTypes(Custom1,{{"Monday Schedule Begin", type time}, {"Monday Schedule End", type time}}),
    Custom2 = Table.Group(#"Changed Type","Resource ID",{"overlap Y/N",each let a=List.RemoveNulls(List.Combine(Table.ToRows(Table.Sort(_,each [#"Work #"])[[Monday Schedule Begin],[Monday Schedule End]]))) in a<>List.Sort(a)})
in
    Custom2

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZBRC4IwEMe/yrBXg01zs96KrCTyQYUI6UF0VBQuih769t0s3bQJ23H873532z/LLMvWztHOrJg/xetRcBQuQdqLxxWNINmJqszfKCnOvHzdOFrw06Uy6EFV/qv1YMYwgdJWBtReveIMVlwI0xnGcCAjpE2xVHM0RrWWd6AJBNZ2KhyzH/OFO4wnx2O1SfG1WlMeJPcORWXdU61U7XJls6QmOuUOGiErG3G7gH2QUeNM2rzkb2YyXwXpAaXxPIzCaG1Y4ONmNTP5yUx2fhmnZw01WKM/yCeGTdovWA86fgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t]),
    Custom1 = Table.PromoteHeaders(Table.Skip(Source)),
    #"Changed Type" = Table.TransformColumnTypes(Custom1,{{"Monday Schedule Begin", type time}, {"Monday Schedule End", type time}}),
    Custom2 = Table.Group(#"Changed Type","Resource ID",{"overlap Y/N",each let a=List.RemoveNulls(List.Combine(Table.ToRows(Table.Sort(_,each [#"Work #"])[[Monday Schedule Begin],[Monday Schedule End]]))) in a<>List.Sort(a)})
in
    Custom2

Thank you for the quick reply! After applying to my non-anonymized dataset, I realized I did a poor job of characterizing my business requirement. However, you have provided the solution to my posted requirement, so I will mark as solved 🙂 May I reach out to you with an different scenario?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors