Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Calculate difference in 2 columns dependant on which date is later in the column headers

Raiden
5 - Atom

Hi,

 

So I'm having trouble trying to figure out how to subtract one column from the next depending on which is the later of the two dates in the column header. I'm trying this as the model will be ran each month and I don't want to have to manually input the dates into the formula like I have done below.

I used crosstab to output the date as the column header as this would have the two dates side-by-side rather than underneath (see input).

 

Now I'm having trouble performing a check along the lines of -> if (date in col 5) later than (date col 6), then (col 5 - col 6) else (col 6 - col 5).

I'm not sure how to determine a formula based off column headers as the dates will just be strings also.


Thanks

 

Raiden_0-1659604382823.png

 

2 REPLIES 2
FilipR
11 - Bolide

This was harder than expected. Please see attached.

 

FilipR_0-1659607724479.png

 

Jay-RDC
8 - Asteroid

Hello,

 

This formula should work. Just make sure that the dates are on date format.

 

If [col 5] > [col 6] then DateTimeDiff([col 5],[col 6], "days") else DateTimeDiff([col 6],[col 5], "days") endif

Labels
Top Solution Authors