Alteryx Designer Desktop Discussions

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

Trying to Join data with matching critera

IMTran
6 - Meteoroid

Hello all, 

 

I have 2 tables with various date times and values. These dates times don't match up exactly. What I'm trying to do is to do a join on the date times of both columns, if table 2 contains a time between a given span. An example below:

 

table 1:

 

Date TimeValue
10/18/2022 17:221
10/18/2022 20:412
10/19/2022 0:363
10/19/2022 2:324
10/19/2022 4:375
10/19/2022 6:336
10/19/2022 7:007
10/19/2022 10:008
10/19/2022 10:049
10/19/2022 22:0010
10/20/2022 2:0011
10/20/2022 6:2712
10/20/2022 10:0013
10/20/2022 14:0014
10/20/2022 21:0715
10/21/2022 10:0016
10/21/2022 14:0017
10/21/2022 19:0018
10/21/2022 22:0019

 

 

table 2

DattimeValue2SpanSpanBackSpanForward
10/18/2022 4:001210/18/2022 2:0010/18/2022 6:00
10/18/2022 5:002210/18/2022 3:0010/18/2022 7:00
10/18/2022 6:003210/18/2022 4:0010/18/2022 8:00
10/18/2022 7:004210/18/2022 5:0010/18/2022 9:00
10/18/2022 8:005210/18/2022 6:0010/18/2022 10:00
10/18/2022 9:006210/18/2022 7:0010/18/2022 11:00
10/18/2022 10:007210/18/2022 8:0010/18/2022 12:00
10/18/2022 11:008210/18/2022 9:0010/18/2022 13:00
10/18/2022 12:009210/18/2022 10:0010/18/2022 14:00
10/18/2022 13:0010210/18/2022 11:0010/18/2022 15:00
10/18/2022 14:0011210/18/2022 12:0010/18/2022 16:00
10/18/2022 15:0012210/18/2022 13:0010/18/2022 17:00
10/18/2022 16:0013210/18/2022 14:0010/18/2022 18:00
10/18/2022 17:0014210/18/2022 15:0010/18/2022 19:00
10/18/2022 18:0015210/18/2022 16:0010/18/2022 20:00
10/18/2022 19:0016210/18/2022 17:0010/18/2022 21:00
10/18/2022 20:0017210/18/2022 18:0010/18/2022 22:00
10/18/2022 21:0018210/18/2022 19:0010/18/2022 23:00
10/18/2022 22:0019210/18/2022 20:0010/19/2022 0:00
10/18/2022 23:0020210/18/2022 21:0010/19/2022 1:00
10/19/202221210/18/2022 22:0010/19/2022 2:00
10/19/2022 1:0022210/18/2022 23:0010/19/2022 3:00
10/19/2022 2:0023210/19/2022 0:0010/19/2022 4:00
10/19/2022 3:0024210/19/2022 1:0010/19/2022 5:00
10/19/2022 4:0025210/19/2022 2:0010/19/2022 6:00
10/19/2022 5:0026210/19/2022 3:0010/19/2022 7:00
10/19/2022 8:0027210/19/2022 6:0010/19/2022 10:00
10/19/2022 9:0028210/19/2022 7:0010/19/2022 11:00
10/19/2022 10:0029210/19/2022 8:0010/19/2022 12:00
10/19/2022 11:0030210/19/2022 9:0010/19/2022 13:00
10/19/2022 12:0031210/19/2022 10:0010/19/2022 14:00
10/19/2022 13:0032210/19/2022 11:0010/19/2022 15:00
10/19/2022 14:0033210/19/2022 12:0010/19/2022 16:00
10/19/2022 15:0034210/19/2022 13:0010/19/2022 17:00
10/19/2022 20:0035210/19/2022 18:0010/19/2022 22:00
10/19/2022 21:0036210/19/2022 19:0010/19/2022 23:00
10/19/2022 22:0037210/19/2022 20:0010/20/2022 0:00
10/19/2022 23:0038210/19/2022 21:0010/20/2022 1:00
10/20/202239210/19/2022 22:0010/20/2022 2:00
10/20/2022 1:0040210/19/2022 23:0010/20/2022 3:00
10/20/2022 2:0041210/20/2022 0:0010/20/2022 4:00
10/20/2022 3:0042210/20/2022 1:0010/20/2022 5:00
10/20/2022 4:0043210/20/2022 2:0010/20/2022 6:00
10/20/2022 5:0044210/20/2022 3:0010/20/2022 7:00
10/20/2022 6:0045210/20/2022 4:0010/20/2022 8:00
10/20/2022 7:0046210/20/2022 5:0010/20/2022 9:00
10/20/2022 8:0047210/20/2022 6:0010/20/2022 10:00
10/20/2022 9:0048210/20/2022 7:0010/20/2022 11:00
10/20/2022 10:0049210/20/2022 8:0010/20/2022 12:00
10/20/2022 11:0050210/20/2022 9:0010/20/2022 13:00
10/20/2022 12:0051210/20/2022 10:0010/20/2022 14:00
10/20/2022 13:0052210/20/2022 11:0010/20/2022 15:00
10/20/2022 14:0053210/20/2022 12:0010/20/2022 16:00
10/20/2022 15:0054210/20/2022 13:0010/20/2022 17:00
10/20/2022 21:0055210/20/2022 19:0010/20/2022 23:00
10/21/2022 12:0056210/21/2022 10:0010/21/2022 14:00
10/21/2022 13:0057210/21/2022 11:0010/21/2022 15:00
10/21/2022 14:0058210/21/2022 12:0010/21/2022 16:00
10/21/2022 15:0059210/21/2022 13:0010/21/2022 17:00
10/21/2022 16:0060210/21/2022 14:0010/21/2022 18:00
10/21/2022 17:0061210/21/2022 15:0010/21/2022 19:00
10/21/2022 18:0062210/21/2022 16:0010/21/2022 20:00
10/21/2022 19:0063210/21/2022 17:0010/21/2022 21:00
10/21/2022 20:0064210/21/2022 18:0010/21/2022 22:00
10/21/2022 21:0065210/21/2022 19:0010/21/2022 23:00
10/21/2022 22:0066210/21/2022 20:0010/22/2022 0:00
10/21/2022 23:0067210/21/2022 21:00

10/22/2022 1:00

 

 

Result of joining:

 

Date TimeValueValue2Explanation
10/18/2022 17:22114.514 15
10/18/2022 20:41217.517 18
10/19/2022 0:36321.521 22
10/19/2022 2:32423.523 24
10/19/2022 4:37525.525 26
10/19/2022 6:336*None
10/19/2022 7:0072727
10/19/2022 10:0082928 29 30
10/19/2022 10:04929.529 30
10/19/2022 22:00103736 27 38
10/20/2022 2:001141.541 42
10/20/2022 6:271245.545 46
10/20/2022 10:001349.549 50
10/20/2022 14:00145352 53 54
10/20/2022 21:07155555
10/21/2022 10:0016*None
10/21/2022 14:00175857 58 59
10/21/2022 19:00186362 63 64
10/21/2022 22:001966

65 66 67

 The last column of the resulting join table is to show the logic.

 

I currently have the work flow to input both tables, and for table 2, I have already been able to have an offset of my time and the span. Currently I'm stuck on this part.

 

IMTran_0-1674829001525.png

 

8 REPLIES 8
RobertOdera
13 - Pulsar

Hi, @IMTran 

 

Here you go.

Your outcome requires profound logic, and I hope the comments in the workflow are helpful.

 

Please see the below.

Please mark it as an acceptable solution if it works for you.

Cheers!

 

For_IMTran.PNG

IMTran
6 - Meteoroid

Wow Robert,

 

Amazing work! Thank you so much.

 

Forgive me, ad you didn't need to do the value 2 explanation, I just wanted to show how the value were derived.

 

I tried adding more columns to table 2, but I got an error.

 

Is it possible for table 2 to merge multiple columns so that you'll have.

Datetime, Value,Value2, value3, value4, etc?

 

RobertOdera
13 - Pulsar

Hi, @IMTran 

 

Thanks for marking ky answer as an acceptable solution.

 

Yes, IMHO, there is always an Alteryx solution.

 

Please provide a before and after for your new requirement, and I will explain how to adapt or extend the above solution so you can do it.

 

Good to know that value 2 is optional, as it takes quite some effort to display the logic rationale.

 

Cheers!

IMTran
6 - Meteoroid

@RobertOdera 
Hi Robert, thank you for the response! This has been a fun problem I've been trying to mess with the past couple of days.

 

The same requirements as before, but, each table could have >100 columns, the example I provided above is just some dummy data. 

 

I still want to be able to joins on date times, where the datetimes don't exactly match. I know that will require some time manipulation in order to get the closest date, and that is fine. If the table 2 date time encompasses multiple dates, I would like to take the average of those values and then join the data. If only 1 datetime in table 1 matches 1 datetime in table 2, we can do just a simple join. 

We also don't need the last column explain what data is merged (that was just to explain the idea), sorry if it added some complications.

 

Please let me know what I can do, it will be of great help.  If you need more clarification, please let me know also

RobertOdera
13 - Pulsar

Sure thing, @IMTran 

 

I will take a look, and I should have a response for you by the end of the day tomorrow (02/15). Cheers!

IMTran
6 - Meteoroid

Thank you so much for your help!

RobertOdera
13 - Pulsar

Here you go @IMTran 

 

-standardized span

-first join is by direct match, second join by proxy match

-transpose configured to anticipate multiple columns dynamically

-read comments in-flow notations and in-calculations

 

Absent an actual washed accurate sample, this is now at diminishing returns for further conceptual treatments.

Still, I hope this helps you - please mark it as an acceptable solution if it works for you. Cheers!

 

RobertOdera_0-1676390036538.png

 

RobertOdera
13 - Pulsar

@IMTran 

You're most welcome!

Please let me/ the community know if you need anything else. Cheers!

Labels