Alteryx Designer Desktop Discussions

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

Advanced cross tab calculation

DM_88
6 - Meteoroid

Hi all

 

I want to do a cross tab calculation but I don't know were to start.

 

The thing that I want to do is transform next data:

IDStartStop
A6/2/2021 0:00:026/2/2021 0:07:32
B6/2/2021 0:00:046/2/2021 0:01:17
C6/2/2021 0:00:056/2/2021 0:00:14
D6/2/2021 0:00:056/2/2021 0:01:21
E6/2/2021 0:00:066/2/2021 0:01:48
F6/2/2021 0:00:076/2/2021 0:03:19
G6/2/2021 0:00:086/2/2021 0:00:10
H6/2/2021 0:00:096/2/2021 0:03:09
I6/2/2021 0:00:106/2/2021 0:00:15
J6/2/2021 0:00:106/2/2021 0:03:07
K6/2/2021 0:00:116/2/2021 0:00:16
L6/2/2021 0:00:146/2/2021 0:00:16

 

Into this:

   Timeline
IDStartStop6/2/2021 0:00:006/2/2021 0:00:016/2/2021 0:00:026/2/2021 0:00:036/2/2021 0:00:046/2/2021 0:00:056/2/2021 0:00:056/2/2021 0:00:066/2/2021 0:00:076/2/2021 0:00:086/2/2021 0:00:096/2/2021 0:00:106/2/2021 0:00:106/2/2021 0:00:116/2/2021 0:00:126/2/2021 0:00:136/2/2021 0:00:146/2/2021 0:00:156/2/2021 0:00:166/2/2021 0:00:17
A6/2/2021 0:00:026/2/2021 0:07:32  111111111111111111
B6/2/2021 0:00:046/2/2021 0:01:17    1111111111111111
C6/2/2021 0:00:056/2/2021 0:00:14     111111111111   
D6/2/2021 0:00:056/2/2021 0:01:21     111111111111111
E6/2/2021 0:00:066/2/2021 0:01:48       1111111111111
F6/2/2021 0:00:076/2/2021 0:03:19        111111111111
G6/2/2021 0:00:086/2/2021 0:00:10         1111       
H6/2/2021 0:00:096/2/2021 0:03:09          1111111111
I6/2/2021 0:00:106/2/2021 0:00:15           1111111  
J6/2/2021 0:00:106/2/2021 0:03:07           111111111
K6/2/2021 0:00:116/2/2021 0:00:16             111111 
L6/2/2021 0:00:146/2/2021 0:00:16                111 
   00112445678101010101011109

7

 

So at the end I want to see how many ID's per second were active.

 

Do's anyone of you have the solution?

 

 Thanks a lot!

6 REPLIES 6
apathetichell
19 - Altair

There are 451 seconds which your rows cover. do you want 451 columns? If I may make a suggestion - take the first and last times. Create rows for each second. Use a batch macro to filter. Do a count of how many active entries there are by second. Oh and do some sweet date/time conversions along the way...

 

Oddly something identical to this suggestion has been attached to this comment.

danilang
19 - Altair
19 - Altair

hi @DM_88 

 

Here's a non macro solution.

 

danilang_0-1625159707700.png

 

The top branch generates all the seconds that each item is active and then groups by second to find the count for each second.  The bottom one generates all possible seconds between the start and the end to fill in any missing gaps.

 

This workflow outputs the list of seconds as rows, because it will be much easier to deal with.   If you require the output in columns, add a crosstab at the end

 

Dan 

 

apathetichell
19 - Altair

@danilangI think the key is "don't have 451 columns"

DM_88
6 - Meteoroid

@apathetichell 

 

Thanks to reply to my topic!

 

U can ignore the DateTime setup, it's the format that our stakeholder is working with 😊 unfortunately I can not open your zip file because you used an newer version as me. For company related reasons we are using 2021.1, but I'm still curious to your solution.

 

Thanks!

DM_88
6 - Meteoroid

@danilang 

 

Thanks to reply to my topic!

 

Your output is indeed what I'm looking for, so that's the reason why I'll flag your post as the solution! 👍

 

Many thanks for helping me! I thought it should be a complex calculation but when I see your flow it looks quit ok 😊

 

Thanks!

apathetichell
19 - Altair

Hi - mine is similar to @danilang 's as it takes max and min times and generates all seconds in between. Mine then uses that as a data source and runs the original into a macro to do the filtering there. It's cleaner - but his way is much more straight forward. 

 

Just today @atcodedog05 posted detailed instructions on how to open workflows created with newer versions of designer in a blog post here: https://community.alteryx.com/t5/Engine-Works/Making-Workflows-Apps-amp-Macros-Backwards-Compatible/...

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels