Alteryx Designer Desktop Discussions

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

Time Difference between different rows given specific criteria

Draymora
6 - Meteoroid

Hello all,

 

Been trying to figure out the best way to approach this - I am trying to get the time difference (minutes) between end time of each event A row compared to the start of event B within the same day & for the same person. Below is some dummy data with an added column of what I'd hope to get:

 

entryPersonDateStartEndEventDesired Resulthow calculated
1X3/1/233:15:35 PM3:30:00 PMA200 minsdiff of end time entry 1 and start time of entry 3 (event B)
2X3/1/234:50:45 PM5:05:00 PMA105 minsTime diff of entry 2 end time and entry 3 start time
3X3/1/236:50:00 PM7:10:00 PMBN/AN/A
4X3/1/237:30:00 PM9:00:00 PMA20 minsTime diff of start time entry 4 and end time of entry 3
5X3/2/234:00:00 PM4:30:00 PMA30 minsTime diff of end time entry 5 and start time of entry 6
6X3/2/235:00:00 PM5:40:00 PMBN/AN/A
7X3/2/237:00:00 PM7:20:00 PMA80 minsTime diff of start time of entry 7 and end time entry 6
8Y3/1/231:00:00 PM1:31:00 PMA209 minsTime diff of end time entry 8 and start time of entry 9
9Y3/1/235:00:00 PM7:00:00 PMBN/AN/A
10Y3/1/237:01:00 PM7:30:00 PMA29 minsTime diff of start time entry 10 and end time entry 9

11

Y

3/1/238:30:00 PM10:00:00 PMA90 minsTime diff of start time entry 11 and end time entry 9 
9 REPLIES 9
martinding
13 - Pulsar

Hi @Draymora,

 

How is this row calculated? 

X3/2/237:00:00 PM7:20:00 PMA

80 mins

 

There doesn't seem to be a corresponding event B that starts after the end time of A.

 

And similarly:

X3/1/237:30:00 PM9:00:00 PMA20 mins
Y3/1/237:01:00 PM7:30:00 PMA30 mins

Y

3/1/238:30:00 PM10:00:00 PMA60 mins
Draymora
6 - Meteoroid

The 80 mins is the 5:40 pm end time of event B to the time the event A starts at 7pm on 3/2 for person X. Trying to get the desired calc

Draymora
6 - Meteoroid

It’s the time difference of the end event B to the start of each A if B is before A, the end of event A to the start of event B if A is before B on same day. Event As could be before or after B. Apologies my desired calc I was trying to mental math the difference. There’s no formula in alteryx currently I’m trying to get the calc 

Draymora
6 - Meteoroid

The 80 mins is the 5:40 pm end time of event B to the time the event A starts at 7pm on 3/2 for person X. Trying to get the desired calc

Qiu
21 - Polaris
21 - Polaris

@Draymora 
I am also a bit confused with the logic here.
Maybe you can add one column to demonstrate how the "Desired Result" is calculated for each row. 

Draymora
6 - Meteoroid

Added additional columns with details 

martinding
13 - Pulsar

Hi @Draymora,

 

I think this is matches the expected logic:

But note for the last 2 rows, I think the original Desired Output contains errors.

 

WARNING: This is not a pretty workflow, and I hope someone can make it more efficient, but it should be the logic you are looking for.

martinding_0-1681168882641.png

 

Draymora
6 - Meteoroid

Thank you for the help! mostly worked - just had to tweak one or two things :) (it kept truncating the before and after lunch fields for some reason). I was wondering - would I be able to use something similar to determine if multiple event As happened back to back as well? (seeing the time difference for these too, same thing with it being within the same day & for each person)

martinding
13 - Pulsar

Hi @Draymora,

 

Yes! In fact, it would actually be easier to do it back to back.

 

So you just need to sort by:

  • Entry No. (If there is such a field and it is in order)

Or

  • Person - Ascending
  • Date - Ascending
  • Start Time - Ascending

 

And perform the Multi-Row calculation:

  • DateTimeDiff([Start Time], [Row-1:End Time], "minute")

This is calculating the difference in minutes between the End Time of the last event (previous row) and the Start Time of the current event (current row). No field needs to be grouped by in this case.

Labels