Alteryx Designer Desktop Discussions

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

Generate Row to incorporate DATEDIFF

DHB
8 - Asteroid

Does any one know how I can insert rows into my data that calculates the DATEDIFF between each Student's last Activity date and the End date in a new column?  In the example below I would like to generate a row after each of the rows with red text.  It would like it to duplicate the first 4 fields, have a null in the Activity field and 11 in the new column for Student 101 (DATEDIFF 31/01/16 and 20/01/16).  Is that possible?

 

 

CourseStartEndStudentActivity
11/01/201631/01/20161011/01/2016
11/01/201631/01/201610110/01/2016
11/01/201631/01/201610111/01/2016
11/01/201631/01/201610112/01/2016
11/01/201631/01/201610120/01/2016
11/01/201631/01/20162022/01/2016
11/01/201631/01/20162026/01/2016
11/01/201631/01/201620211/01/2016
11/01/201631/01/201620220/01/2016
11/01/201631/01/201620231/01/2016
11/01/201631/01/20163031/01/2016
11/01/201631/01/201630320/01/2016
11/01/201631/01/201630321/01/2016
11/01/201631/01/201630322/01/2016
11/01/201631/01/201630330/01/2016
21/01/201631/01/201610110/01/2016
21/01/201631/01/201610113/01/2016
21/01/201631/01/201610119/01/2016
21/01/201631/01/201610122/01/2016
21/01/201631/01/201610123/01/2016
21/01/201631/01/20164045/01/2016
21/01/201631/01/20164046/01/2016
21/01/201631/01/201640418/01/2016
21/01/201631/01/201640424/01/2016
21/01/201631/01/201640431/01/2016
21/01/201631/01/20165059/01/2016
21/01/201631/01/201650511/01/2016
21/01/201631/01/201650521/01/2016
21/01/201631/01/201650522/01/2016
21/01/201631/01/201650530/01/2016

 

Thank tou in advance for your help.

 

DHB.

8 REPLIES 8
Joe_Mako
12 - Quasar

How about the attached?

 

activity.png


Sort - ensure correct sorting
Multi-Row Formula - Add an ActivityID field, for use sorting later
Sample - Last record per Course-Student combination
Formula - Calculate Difference in days, increment ActivityID, Null for Activity
Union - Append with data from before Sample
Sort - get final requested sort order

DHB
8 - Asteroid

That works perfectly, thank you Joe.  I'd been trying to generate rows and it wasn't working.

RodL
Alteryx Alumni (Retired)

So I like to look at some of these questions and come up with an answer, but when I find that someone has already answered with a working solution like one of brilliant our ACEs, @Joe_Mako, I usually let it go.

 

But in this case, while the basic principle of creating a separate record and then unioning back with the original data set was also in my solution, I had approached the creation of the record a bit differently. And in the spirit of showing people that there are multiple ways to approach a problem, I figured I'd post my solution as well. Not that mine is better...just different...but I think we get the same result.  Smiley Wink

 

activity2.png

DHB
8 - Asteroid

Thank you for sharing your solution Rod.  I'm new to Alteryx so it's good to see differnet ways of doing things.

Joe_Mako
12 - Quasar

Nice work Rod!

 

I like how you sorted by Difference and then Activity to get the Null date last. I agree, it is great to see other routes. Thank you for not letting it go. I would love to see your take on other threads that I replied to. Thank you!

DHB
8 - Asteroid

Following on from the above I'm now looking to convert the data so that each students activity in each course would be represented something like this;

 

DateDate NumberStartEndActivityActivity NumberStudentCourse
1/01/201611/01/201631/01/20161/01/201611011
2/01/201621/01/201631/01/2016nullnullnullnull
3/01/201631/01/201631/01/2016nullnullnullnull
4/01/201641/01/201631/01/2016nullnullnullnull
5/01/201651/01/201631/01/2016nullnullnullnull
6/01/201661/01/201631/01/2016nullnullnullnull
7/01/201671/01/201631/01/2016nullnullnullnull
8/01/201681/01/201631/01/2016nullnullnullnull
9/01/201691/01/201631/01/2016nullnullnullnull
10/01/2016101/01/201631/01/201610/01/201621011
11/01/2016111/01/201631/01/201611/01/201631011
12/01/2016121/01/201631/01/201620/01/201641011
13/01/2016131/01/201631/01/2016nullnullnullnull
14/01/2016141/01/201631/01/2016nullnullnullnull
15/01/2016151/01/201631/01/2016nullnullnullnull
16/01/2016161/01/201631/01/2016nullnullnullnull
17/01/2016171/01/201631/01/2016nullnullnullnull
18/01/2016181/01/201631/01/2016nullnullnullnull
19/01/2016191/01/201631/01/2016nullnullnullnull
20/01/2016201/01/201631/01/201620/01/201651011
21/01/2016211/01/201631/01/2016nullnullnullnull
22/01/2016221/01/201631/01/2016nullnullnullnull
23/01/2016231/01/201631/01/2016nullnullnullnull
24/01/2016241/01/201631/01/2016nullnullnullnull
25/01/2016251/01/201631/01/2016nullnullnullnull
26/01/2016261/01/201631/01/2016nullnullnullnull
27/01/2016271/01/201631/01/2016nullnullnullnull
28/01/2016281/01/201631/01/2016nullnullnullnull
29/01/2016291/01/201631/01/2016nullnullnullnull
30/01/2016301/01/201631/01/2016nullnullnullnull
31/01/2016311/01/201631/01/2016nullnullnullnull

 

This shows Student 101 in Course 1 but I would like to generate a row for every day of the course for each student in whatever Course they're in.  I've been toiling away with only very modest progress so far.

 

Does anyone have any suggestions?

 

Thank you in advance for your help.

 

DHB

Joe_Mako
12 - Quasar

Does the attached get you closer?

DHB
8 - Asteroid

Thank you so much again Joe.  It got me all the way there.  I added a simple formula to the multiple join tool, sorted it after that and it works perfectly.

 

Best,

 

DHB

Labels