/    /  Amazon QuickSight – isWorkDay

Amazon QuickSight – isWorkDay

 

In Amazon QuickSight isWorkDay is a function that determines whether a given date is a workday or not. The function takes one parameter, inputDate, which is the date to be evaluated. If the date falls on a weekend or is a holiday, the function returns false; otherwise, it returns true.

 

Syntax

 

#Start#
isWorkDay(inputDate)
#End#

 

This function takes one argument

  1. inputDate: This is the date to be evaluated. Valid values are as follows:
  • Dataset fields: Any date field from the dataset that you are adding this function to.
  • Date Functions: Any date output from another date function, for example, parseDate.
  • Calculated fields: Any QuickSight calculated field that returns a date value.
  • Parameters: Any QuickSight DateTime parameter.

 

For example, suppose we have a QuickSight dataset with a field called “OrderDate” that contains dates, and we want to create a calculated field that indicates whether an order was placed on a workday or not. We can use the isWorkDay() function to create this calculated field. The following expression returns true if the “OrderDate” falls on a workday and false otherwise:

Example

#Start#
isWorkDay({OrderDate})
#End#

 

In this example, {OrderDate} is a reference to the “OrderDate” field in the dataset. If the “OrderDate” falls on a weekend or holiday, the expression evaluates to false; otherwise, it evaluates to true.

 

Note that the isWorkDay() function considers weekends as non-workdays, but it does not include holidays by default. If you want to exclude additional holidays from your workday calculations, you can use the holiday() function to define your own list of holidays. For example, the following expression returns true if the “OrderDate” falls on a workday and does not fall on Christmas Day or New Year’s Day:

Example

#Start#
isWorkDay({OrderDate}) and not(holiday({OrderDate}) in ["12/25", "01/01"])
#End#

 

In this example, the not() function is used to negate the result of the holiday() function, which returns true if the “OrderDate” falls on Christmas Day or New Year’s Day, and the in operator is used to check if the holiday falls on one of the dates in the list. The and operator is used to combine the two conditions into a single expression.