Count Weekdays between two dates in Alteryx.

by Brandon Fitz-Gerald

The use of the datediff formula in Alteryx makes it easy to count how many days there are between two dates, but what if you only wanted to count the weekdays?

Here’s the method I use, and it can be done is as little as 4 tools. I’ve counted the number of weekdays between Order Date and Ship Date in the Sample Superstore data.

Figure 1: Total Alteryx Workflow for counting weekdays between two dates.

The select tool is optional, I’ve added it here to narrow down the number of fields to only those I’ll be using in the workflow.

Generate Rows Tool|

Figure 2: Setup for the generate rows tool

This tool will create a new row for every date between the [Order Date] and the [Ship Date]. Each row is generated with the date being one day further along than the previous row.

Formula Tool|

Figure 3: Setup for the formula tool

This tool will create a new field, calculating the day of the week for every date in the DateBetween field (Created in the previous tool).

Filter Tool|

Figure 4: Setup for the Filter Tool

This will filter out any rows where the Day of the Week was a Saturday or Sunday (The Weekend), leaving only the weekdays.

Summarize Tool|

Figure 5: Setup for the summarize tool.

This setup means the tool will group any rows containing the same OrderID together. Within these groups the daysofweek are counted. The outcome of this count will the number of weekdays between our Order Date and Ship Date.

I hope you’ve found this quick Alteryx tip helpful. I know when I found out it was definitely useful for me.

© 2022 The Information Lab Ltd. All rights reserved.