Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

How to check if the date in the current row is 1 day after the previous row?

danielstefanng
7 - Meteor

Hi,

 

I need to get Alteryx (I am assuming the Multi RowFormula tool) to fill out the 'Is the current date a day after the previous date? (Yes/No)' field. The values in the chart belowis what I would expect it to be.

 

Basically, I need the check if the 'Date' in the current row is 1 day after the previous row, and then populate the mentioned column with 'Yes' or 'No' accordingly.

 

I would also need to group this by Name. Please note I have already sorted my data by Name, and then by Date.

 

NameDateIs the current date a day after the previous date? (Yes/No)Comment
James23/07/2018NoThis is a No because it is the first date for that name, therefore there is no previous date.
James3/09/2018NoNo, because the date in this row is not a day after the date in the row above.
James6/09/2018NoNo, because the date in this row is not a day after the date in the row above.
James22/10/2018NoNo, because the date in this row is not a day after the date in the row above.
James23/10/2018YesYes, because the date in this row is a day after the date in the row above.
James24/10/2018YesYes, because the date in this row is a day after the date in the row above.
James25/10/2018YesYes, because the date in this row is a day after the date in the row above.
Anne23/07/2018NoThis is a No because it is the first date for that name, therefore there is no previous date.
Anne24/07/2018YesYes, because the date in this row is a day after the date in the row above.
Anne25/07/2018YesYes, because the date in this row is a day after the date in the row above.
Anne26/07/2018YesYes, because the date in this row is a day after the date in the row above.
Anne30/07/2018NoNo, because the date in this row is not a day after the date in the row above.
Anne31/07/2018YesYes, because the date in this row is a day after the date in the row above.
Anne31/07/2018NoNo, because this line has the same date as the line above.

 

 

 

Thanks for your assistance.

 

Kind regards,

Daniel

5 REPLIES 5
DavidP
17 - Castor
17 - Castor

Hi Daniel,

 

Yes you can do it with Multi Row formula, but in order to do date calculations, you just have to convert your date to the Alteryx date format, like this. Also see workflow attached.

 

next day.png

danielstefanng
7 - Meteor

Thanks David,

 

However, I am getting the attached errors . Apologies, should've mentioned that my current dates are in this format:

 

YYYY-MM-DD and as per your instructions, should be converted to DD/MM/YYYY. Thanks for your assistance.

 

 

 

Kind regards,

Daniel

 

 

 

danielstefanng
7 - Meteor

No worries, all good. I didn't have to convert the date because Alteryx recognises the YYYY-MM-DD format, so the formula below worked.

 

if datetimediff([Date],[Row-1:Date],'days')=1 then 'Yes' else 'No' endif

 

Thanks again,

Daniel

Hakimipous
10 - Fireball

@danielstefanng please make sure to mark that post as solved if this is the case :)

DavidP
17 - Castor
17 - Castor

Yes, yyyy-mm-dd is actually the Alteryx date format. The reason I used datetimeparse in my first post was because the dates in your original post was shown as dd/mm/yyyy. In this case, the date has to be converted to the Alteryx format.

 

Anyway, glad you got it working.

Labels