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

Count workday difference between 2 dates

Eliot_with_cat
7 - Meteor

Hi All,

 

Recently I am working on report automation related to the maturity date difference calculation. We just count workdays in the calculation.

In the forum, I could find many great workflows how to calculate the workdays. Nevertheless, it seems most of them require the steps to define Sat and Sun before we can filter out the weekdays for further calculation.

With loads of entries, Alteryx requires defining Sat and Sun repeatedly in date difference of each entry and it slowed down the performance.

Any ways we can skip the Sat and Sun definition step or just define one time only and applied to all other entries?

 

Eliot 

8 REPLIES 8
jdunkerley79
ACE Emeritus
ACE Emeritus

Assuming you are only dealing with Saturdays and Sundays you can do this using a formula.

 

If you can use a third party library then I have BUSINESSDAYS function within my Alteryx Abacus function library. This reproduces the Excel  NETWORKDAYS function.

 

 Alternatively you can use :

1 + ((DateTimeDiff(End,Start,"days")*5 - (ToNumber(DateTimeFormat(Start, "%w"))-ToNumber(DateTimeFormat(End, "%w")))*2) / 7) + 
IIF(DateTimeFormat(End, "%w")=="6",-1,0) + IIF(DateTimeFormat(Start, "%w")=="0",-1,0)

Sample attached

 

Eliot_with_cat
7 - Meteor

Very useful! Really help speed up the whole process, thanks!!!

lisaac
5 - Atom

Awesome, how cool is that formula!

 

Does make me wonder though (as a pure newbie to Alteryx), why it's not in the base toolset (or is it now?), given how popular it's use is in Excel.

Robert2
7 - Meteor

Solution

Eliot_with_cat
7 - Meteor

You are right. Aniticipating Alteryx team to build the workday formula function for us.

LisaLeach
6 - Meteoroid
Hello, I would like to add one more layer to this, how do you remove holidays?
apathetichell
19 - Altair

hi @LisaLeach - this is a fairly old thread - you may want to start a new one... but also there are a few weekly challenges on this subject. Perhaps this will help?

https://community.alteryx.com/t5/Weekly-Challenge/Challenge-248-Holidates/td-p/685824

 

If you do start a new thread it helps to include sample data and details of how the information on holidays comes into the workflow (file, manually set, user entered, etc.).

LisaLeach
6 - Meteoroid
Ok, I will do that.
Labels