Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Multi Row Formula - Subtract Date/Days Row 1 from Row 2, and so on.

wonka1234
10 - Fireball

Hi,

 

I am trying to use multi row formula with this logic: Subtract Date/Days Row 1 from Row 2, and so on.

 

wonka1234_1-1654109931401.png

 

 

wonka1234_0-1654109911480.png

 

I am getting an error here formula invalid type in subtraction operator.

 

6 REPLIES 6
phottovy
13 - Pulsar
13 - Pulsar

Hi @wonka1234 ,

 

There are two things you need to consider to get this to work. First, is your date field formatted as a Date type? If not, it will treat the field as a string and won't know how to subtract. Second, you can use the DateTimeDiff() function to find the difference between two dates:

DateTimeDiff([PMT Date], [Row-1:PMT Date], 'days')

I have attached a workflow that both converts the field to a date format and then uses a multi-row tool with the DateTimeDiff function.

binuacs
21 - Polaris

@wonka1234 Another way of doing this

 

binuacs_0-1654114412389.png

 

wonka1234
10 - Fireball

Thanks for this! 

Do you know how to reverse getting null in first row? would like the null to be in last row.

 
 
 
 
 
 
 
binuacs
21 - Polaris

@wonka1234 you need to adjust the formula in the Multi_Row tool

 

DateTimeDiff(DateTimeParse([Row+1:PMT Date String],'%m/%d/%Y'),DateTimeParse([PMT Date String],'%m/%d/%Y'),'days')

 

binuacs_0-1654114864152.png

 

phottovy
13 - Pulsar
13 - Pulsar

As @binuacs pointed out, you just need to modify the formula slightly to use row +1 first: 

DateTimeDiff([Row+1:PMT Date], [PMT Date], 'days')

 

binuacs
21 - Polaris

@wonka1234 Thanks for accepting my solution,  you can also mark multiple solutions as accepted solution if they can solve your use case. I can see  @phottovy solution is just another way of doing the same.

Labels