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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Conditional Join on "Line Name" and Data Range

Hello:

 I am trying to join two tables by "Line Name" with table one filtering the data in table two by date range such that table table two to only show data WHERE "timestamp" falls within the "SHIFT PERIOD START" AND "SHIFT PERIOD END" and WHERE "LINE NAME = "LINE NAME". Tried the community but I am not able to get it. Any help would be greatly appreciated. Thanks 

Table one: Shift Filter from Teams: Shifts

LINE NAMESHIFT IS ACTIVESHIFT START DATE AND TIMESHIFT END DATE AND TIMESHIFT PERIOD IS SCHEDULED ACVTIVESHIFT PERIOD STARTSHIFT PERIOD ENDSHIFT PERIOD ID CODESHIFT PERIOD NAME
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 8:15:00 AM4/20/2020 9:00:00 AMFwFIrst Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 8:15:00 AM4/20/2020 9:00:00 AMFwFIrst Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 8:15:00 AM4/20/2020 9:00:00 AMFwFIrst Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 8:15:00 AM4/20/2020 9:00:00 AMFwFIrst Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 8:15:00 AM4/20/2020 9:00:00 AMFwFIrst Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 8:15:00 AM4/20/2020 9:00:00 AMFwFIrst Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 8:15:00 AM4/20/2020 9:00:00 AMFwFIrst Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 8:15:00 AM4/20/2020 9:00:00 AMFwFIrst Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 9:15:00 AM4/20/2020 12:00:00 PMSwSecond Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 9:15:00 AM4/20/2020 12:00:00 PMSwSecond Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 9:15:00 AM4/20/2020 12:00:00 PMSwSecond Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 9:15:00 AM4/20/2020 12:00:00 PMSwSecond Work Period
CX482 MAIN LINE SANDBOXTRUE4/20/2020 8:00:00 AM4/20/2020 5:00:00 PMTRUE4/20/2020 9:15:00 AM4/20/2020 12:00:00 PMSwSecond Work Period

 

 

 

 

Table Two: Machine State data

error textcategory numcategory texttimestamptime no millisIndexshort nameLine Name
S040 MACHINE IS BLOCKED5MACHINE BLOCKED3/6/2020 12:313/6/2020 12:311CX482 S040CX482 MAIN LINE SANDBOX
+S040 RC2 ROBOT GRIPPER PART PRESENT LH MISSING1MACHINE ERRORS3/6/2020 12:313/6/2020 12:312CX482 S040CX482 MAIN LINE SANDBOX
+S040_ROBOT ARM RC1_R2 EXECUTION ERROR1MACHINE ERRORS3/6/2020 12:313/6/2020 12:313CX482 S040CX482 MAIN LINE SANDBOX
+S040 RC2 ROBOT GRIPPER PART PRESENT LH MISSING1MACHINE ERRORS3/6/2020 12:313/6/2020 12:314CX482 S040CX482 MAIN LINE SANDBOX
+S040_ROBOT ARM RC1_R2 EXECUTION ERROR1MACHINE ERRORS3/6/2020 12:313/6/2020 12:315CX482 S040CX482 MAIN LINE SANDBOX
+S040 RC2 ROBOT GRIPPER PART PRESENT LH MISSING1MACHINE ERRORS3/6/2020 12:313/6/2020 12:316CX482 S040CX482 MAIN LINE SANDBOX
+S040_ROBOT ARM RC1_R2 EXECUTION ERROR1MACHINE ERRORS3/6/2020 12:313/6/2020 12:317CX482 S040CX482 MAIN LINE SANDBOX
+S040 RC2 ROBOT GRIPPER PART PRESENT LH MISSING1MACHINE ERRORS3/6/2020 12:313/6/2020 12:318CX482 S040CX482 MAIN LINE SANDBOX
+S040_ROBOT ARM RC1_R2 EXECUTION ERROR1MACHINE ERRORS3/6/2020 12:313/6/2020 12:319CX482 S040CX482 MAIN LINE SANDBOX
+S040 RC2 ROBOT GRIPPER PART PRESENT LH MISSING1MACHINE ERRORS3/6/2020 12:313/6/2020 12:3110CX482 S040CX482 MAIN LINE SANDBOX
+S040_ROBOT ARM RC1_R2 EXECUTION ERROR1MACHINE ERRORS3/6/2020 12:313/6/2020 12:3111CX482 S040CX482 MAIN LINE SANDBOX
1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can merge tables based on Line name and filter the table based on the new custom column 

 

let
    Source = Table.NestedJoin(Shifts, {"LINE NAME"}, #"Machine State data", {"Line Name"}, "Machine State data", JoinKind.LeftOuter),
    #"Expanded Machine State data" = Table.ExpandTableColumn(Source, "Machine State data", {"timestamp"}, {"Machine State data.timestamp"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Machine State data", "Custom", each [Machine State data.timestamp]>=[SHIFT PERIOD START] and[Machine State data.timestamp]<=[SHIFT PERIOD END]),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> false))
in
    #"Filtered Rows"

 

 Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can merge tables based on Line name and filter the table based on the new custom column 

 

let
    Source = Table.NestedJoin(Shifts, {"LINE NAME"}, #"Machine State data", {"Line Name"}, "Machine State data", JoinKind.LeftOuter),
    #"Expanded Machine State data" = Table.ExpandTableColumn(Source, "Machine State data", {"timestamp"}, {"Machine State data.timestamp"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Machine State data", "Custom", each [Machine State data.timestamp]>=[SHIFT PERIOD START] and[Machine State data.timestamp]<=[SHIFT PERIOD END]),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> false))
in
    #"Filtered Rows"

 

 Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Frank:

 Super Thanks for the DAX. THe .pbix file really helped as well so thank you for your time to make that. Now that i can see the method I understand it. Your help has allowed us to use the Teams shift schedule to filter machine state data. This should improve my report data accuracy significantly. Thank you again for your help.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.