Cal11 calculator

Tableau Calculated Field Show Weekdays Without Holidays

Reviewed by Calculator Editorial Team

This guide explains how to create a Tableau calculated field that shows only weekdays (Monday through Friday) while excluding holidays. This is useful for business analytics, project planning, and any scenario where you need to exclude weekends and holidays from your date calculations.

Introduction

In Tableau, calculated fields allow you to create custom calculations based on your data. One common requirement is to filter dates to show only weekdays (Monday-Friday) while excluding weekends and holidays. This guide will walk you through creating such a calculated field in Tableau.

Why would you need this? Imagine you're analyzing sales data and want to exclude weekends and holidays when calculating average daily sales. Or perhaps you're tracking project milestones and need to exclude non-working days from your timeline calculations.

How to Create the Calculated Field

  1. Open your Tableau workbook and connect to your data source.
  2. Right-click on the date field you want to filter in the Data pane.
  3. Select "Create" > "Calculated Field".
  4. In the Calculated Field dialog box, name your field something descriptive like "Weekdays Without Holidays".
  5. Enter the formula (we'll explain this in detail in the next section).
  6. Click OK to create the calculated field.
  7. Drag the new calculated field to the Filters shelf.
  8. Select "True" to filter your data to show only weekdays without holidays.

Formula Explanation

The formula for this calculated field combines two checks:

// Check if the date is a weekday (Monday-Friday)
// AND if it's not a holiday
IF (WEEKDAY([Date Field]) < 6) AND NOT (ISDATE([Date Field], [Holiday List])) THEN TRUE ELSE FALSE END

Let's break this down:

  • The WEEKDAY function returns a number (1-7) representing the day of the week, where 1 is Sunday and 7 is Saturday.
  • We check if the weekday is less than 6, which means Monday (1) through Friday (5).
  • The ISDATE function checks if the date exists in a list of holidays.
  • We use NOT to exclude holidays from our weekday check.
  • The final IF statement returns TRUE for dates that are weekdays and not holidays, FALSE otherwise.

Note: You'll need to create a separate data source or parameter containing your list of holidays for this formula to work.

Example

Let's say you have a sales dataset with dates from January 1, 2023 to January 31, 2023. Your holidays for this period are January 1 (New Year's Day) and January 16 (Martin Luther King Jr. Day).

Using our calculated field, Tableau would:

  • Show all Monday-Friday dates in January 2023
  • Exclude weekends (Saturday and Sunday)
  • Exclude January 1 and January 16 (your holidays)

This would give you 20 working days in January 2023 (23 total days minus 3 weekends minus 2 holidays).

Date Day Is Holiday? Included in Calculation?
2023-01-01 Sunday Yes No
2023-01-02 Monday No Yes
2023-01-03 Tuesday No Yes
2023-01-04 Wednesday No Yes
2023-01-05 Thursday No Yes
2023-01-06 Friday No Yes
2023-01-07 Saturday No No
2023-01-08 Sunday No No
2023-01-16 Monday Yes No

Best Practices

Creating Your Holiday List

For the calculated field to work, you need a list of holidays. You can create this in several ways:

  • Create a separate data source with a column for dates and a column indicating if it's a holiday
  • Use a Tableau parameter with a list of dates
  • Connect to an external calendar service that provides holiday data

Tip: Consider creating a separate "Holidays" data source that you can join to your main data source when needed.

Testing Your Calculated Field

Always test your calculated field with different date ranges to ensure it works as expected. Check edge cases like:

  • Dates at the beginning and end of months
  • Dates around holiday periods
  • Leap years (February 29)

Performance Considerations

If you're working with large datasets, be mindful of performance. Complex calculated fields can slow down your workbook. Consider:

  • Using extract filters instead of calculated fields when possible
  • Creating pre-filtered extracts
  • Using Tableau's performance recording feature to identify bottlenecks

FAQ

Can I use this calculated field with continuous dates?
Yes, this calculated field works with both discrete and continuous dates. When used with continuous dates, it will highlight the weekdays without holidays on the date axis.
How do I update the holiday list?
The method for updating holidays depends on how you've created your holiday list. If you're using a separate data source, you can refresh that data connection. If you're using a parameter, you'll need to manually update the parameter values.
Can I use this calculated field with multiple date fields?
Yes, you can create multiple calculated fields, each referencing a different date field, to filter different date dimensions in your workbook.
What if I need to exclude different holidays for different regions?
You can create separate calculated fields for different regions, each with its own holiday list. Alternatively, you could create a more complex calculated field that checks for holidays based on a region parameter.