Alteryx Designer Desktop Discussions

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

Calculate days between 2 dates with a condition

itsmeanuj
7 - Meteor

Hi,

 

I want to calculate Hold days (see column Status code) before 1st shipment. Here are the conditions

 

1. Hold days should exclude weekends
2. Hold days should be calculated between the status code "Hold" and any other status (New, ready, etc)

 

 

Expected Outputs

1. for Patient ID 10001, hold days will be 2 days (12-09-2020 - 12-07-2020)
2. For patient ID 10002, Hold days will be 22 days ((10-07-2021 - 09-09-2021 - weekend days = 20 days) & (10-14-2021 - 10-12-2021 = 2 days)).


We do have thousands of patient IDs in our data and want to calculate hold days for all of them. If someone can guide on how we can achieve this in Alteryx?


Thanks,
Anuj

14 REPLIES 14
itsmeanuj
7 - Meteor

Sure! so if you see my original post (point 2 in expected output) - once the shipment is done on 10/14/2021, we don't have to consider Hold status after that. Idea is to calculate the hold days only till the first shipment is done. Please consider column D as the expected output in the attached excel. 

 

Expected Outputs

1. for Patient ID 10001, hold days will be 2 days (12-09-2020 - 12-07-2020)
2. For patient ID 10002, Hold days will be 22 days ((10-07-2021 - 09-09-2021 - weekend days = 20 days) & (10-14-2021 - 10-12-2021 = 2 days)).

 

Thanks,

Anuj

ShankerV
17 - Castor

Hi @itsmeanuj 

 

Please find the revised solution where Hold will not be considered after Shipment for each Patient ID.

 

ShankerV_0-1672073644299.png

 

Note: The workflow used to achieve the solution is attached which can be downloaded to see how the solution works.

 

If you believe your problem has been resolved. Please mark helpful answers as a solution so that future users with the same problem can find them more easily!!!!

 

Many thanks

Shanker V

 

ShankerV
17 - Castor

Hi @itsmeanuj 

 

I have added just 2 tools to amend the output.

 

Used this formula in Multi row formula 

if ([Status Code]="SHIPMENT")
then 1
elseif [Row-1:Patient ID]=[Patient ID] AND [Row-1:New Field]=1
then 1
else 0
endif

 

 

ShankerV_0-1672073870095.png

 

Then one more main note, I have updated my alteryx version hence the date format in the input file was in MM-DD-YYYY but my current alteryx version read the file correctly as YYYY-MM-DD as per alteryx format.

 

ShankerV_1-1672073972847.png

 

Hence I have removed my Date-Time format tool, in the below location.

ShankerV_2-1672074031686.png

 

Hope my solution will work in your system also as per the same input file used at your end.

 

 

If you believe your problem has been resolved. Please mark helpful answers as a solution so that future users with the same problem can find them more easily!!!!

 

Many thanks

Shanker V

 

 

itsmeanuj
7 - Meteor

Thank you so much Shanker! It worked as expected.

ShankerV
17 - Castor

Hi @itsmeanuj 

 

Welcome, happy to support anytime!!!!

Happy new year in advance!!!

Labels