Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Join by two fields, first by exact string match, then DateTime approximate match

javiroca
5 - Atom

Hi! My first post here, I have been searching the forums but no other question seems to match my problem

 

I have 2 tables (I will simplify for the question purposes)

 

The first one is a set of measurements taken once per second on different vehicles while on the assembly line:

 

VINMeasurement_DateTimeMeasurement_Value
AABBCCDDEEFFGG2023-07-17 14:19:554.79788
AABBCCDDEEFFGG2023-07-17 14:19:564.89238
..............
HHIIJJKKLLMMNNOO2023-07-19 14:25:450.408938
HHIIJJKKLLMMNNOO2023-07-19 14:25:460.4075
............

 

 

The second table is a set of records of vehicles passing through different assembly line stations, relevant fields below:

 

VINStation_Start_DateTimeStation Name
AABBCCDDEEFFGG2023-07-17 14:19:01Station A
AABBCCDDEEFFGG2023-07-17 14:29:35Station B
AABBCCDDEEFFGG2023-07-17 14:39:15Station C
HHIIJJKKLLMMNNOO2023-07-19 14:16:15Station A
HHIIJJKKLLMMNNOO2023-07-19 14:23:36Station B
HHIIJJKKLLMMNNOO2023-07-19 14:28:32Station C

 

Desired Output: For every measurement taken, add a field with the station name where the vehicle was at the DateTime when the measurement was taken. We can assume that each station starts on Station_Start_DateTime and ends just before the next station

 

VINMeasurement_DateTimeMeasurement_ValueStation_Name
AABBCCDDEEFFGG2023-07-17 14:19:554.79788Station A
AABBCCDDEEFFGG2023-07-17 14:19:564.89238Station A
.............. 
HHIIJJKKLLMMNNOO2023-07-19 14:25:450.408938Station B
HHIIJJKKLLMMNNOO2023-07-19 14:25:460.4075Station B
............ 

 

This is how I am doing it now, but it is extremely inefficient, as the Join block generates GB's of data when combining both tables. My dataset will grow over time, I just measured 2 vehicles and the PC struggles. I need to find a better solution as I need to measure tens of vehicles.

 

Screenshot 2023-08-03 105226.png

 

Thank You!

Javier

5 REPLIES 5
javiroca
5 - Atom

Forgot to mention that there could be multiple records for each station in the second input table, as each process within the station generates a record. Thanks

Christina_H
14 - Magnetar

How about something like this that generates a row for every second at that station?

image.png

Christina_H
14 - Magnetar

Or alternatively, construct a formula from the second input to calculate which station is correctimage.png

javiroca
5 - Atom

Thank you, Christina! It seems to work. Just for my education, I don't understand what the marcro does, is there a way to see the code inside the macro? 

While importing you workflow I got a few errors due to my Alteryx version being older than yours, not sure if that has anything to do.

Thanks again,

Javier

Christina_H
14 - Magnetar

Hi @javiroca, if the workflow imported correctly you should be able to right click on the macro to open it (option at the bottom of the menu).  But it's a very simple one - just replacing a fixed station value with the calculated formula instead.

image.png

As for the versions, I don't think I've used anything specific to the latest versions of Alteryx so hopefully after warning you it will all work correctly!

Labels
Top Solution Authors