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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors