The lastworkdate function returns
the earliest ending date to achieve no_of_workdays
(Monday-Friday) if starting at start_date
taking into account any optionally listed holiday.
start_date and holiday
should be valid dates or timestamps.
A calendar that shows how the lastworkdate() function is used
Limitations
There is no method to modify the lastworkdate() function for regions or scenarios that involve anything other than a work week that begins on Monday and ends on Friday.
The holiday parameter must be a string constant. It does not accept an expression.
When to use it
The lastworkdate() function is commonly used as part of an expression when the user would like to calculate the proposed end date of a project or assignment, based on when the project begins and the holidays that will occur in that period.
Regional settings
Unless otherwise specified, the examples in this topic use the following date format: MM/DD/YYYY. The date format is specified in the SET DateFormat statement in your data load script. The default date formatting may be different in your system, due to your regional settings and other factors. You can change the formats in the examples below to suit your requirements. Or you can change the formats in your load script to match these examples. For more information, see Modifying regional settings for apps and scripts.
Default regional settings in apps are based on the user profile. These regional format settings are not related to the language displayed in the Qlik Cloud user interface. Qlik Cloud will be displayed in the same language as the browser you are using.
Holiday periods to exclude from working days. A holiday is stated as a string constant date. You can specify multiple holiday dates, separated by commas.
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset containing project IDs, project start dates, and the estimated effort, in days, required for the projects. The dataset is loaded into a table called ‘Projects’.
A preceding load which contains the lastworkdate() function which is set as the field ‘end_date’ and identifies when each project is scheduled to end.
Load the data and open a sheet. Create a new table and add these fields as dimensions:
id
start_date
effort
end_date
Results table
id
start_date
effort
end_date
1
01/01/2022
14
01/20/2022
2
02/10/2022
17
03/04/2022
3
05/17/2022
5
05/23/2022
4
06/01/2022
12
06/16/2022
5
08/10/2022
26
09/14/2022
Because there are no scheduled holidays, the function adds the defined number of working days, Monday to Friday, to the start date to find the earliest possible end date.
The following calendar shows the start and end date for project 3, with the working days highlighted in green.
A calendar that shows the start and end date of project 3
Example 2 - Single holiday
Overview
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset containing project IDs, project start dates, and the estimated effort, in days, required for the projects. The dataset is loaded into a table called ‘Projects’.
A preceding load which contains the lastworkdate() function which is set as the field ‘end_date’ and identifies when each project is scheduled to end.
However, there is one holiday scheduled on May 18, 2022. The lastworkdate() function in the preceding load includes the holiday in its third argument to identify when each project is scheduled to end.
Load the data and open a sheet. Create a new table and add these fields as dimensions:
id
start_date
effort
end_date
Results table
id
start_date
effort
end_date
1
01/01/2022
14
01/20/2022
2
02/10/2022
17
03/04/2022
3
05/17/2022
5
05/24/2022
4
06/01/2022
12
06/16/2022
5
08/10/2022
26
09/14/2022
The single scheduled holiday is entered as the third argument in the lastworkdate() function. As a result, the end date for project 3 is shifted one day later because the holiday takes place on one of the working days before the end date.
The following calendar shows the start and end date for project 3 and shows that the holiday changes the end date of the project by one day.
A calendar that shows the start and end date of project 3 with a holiday on May 18
Example 3 - Multiple holidays
Overview
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset containing project IDs, project start dates, and the estimated effort, in days, required for the projects. The dataset is loaded into a table called ‘Projects’.
A preceding load which contains the lastworkdate() function which is set as the field ‘end_date’ and identifies when each project is scheduled to end.
However, there are three holidays scheduled for May 19, 20, 21, and 22. The lastworkdate() function in the preceding load includes each of the holidays in its third argument to identify when each project is scheduled to end.
Load the data and open a sheet. Create a new table and add these fields as dimensions:
id
start_date
effort
To calculate the end_date, create the following measure:
=LastWorkDate(start_date,effort,'05/18/2022')
Results table
id
start_date
effort
=LastWorkDate(start_date,effort,'05/18/2022')
1
01/01/2022
14
01/20/2022
2
02/10/2022
17
03/04/2022
3
05/17/2022
5
05/23/2022
4
06/01/2022
12
06/16/2022
5
08/10/2022
26
09/14/2022
The single scheduled holiday is entered as a measure in the chart. As a result, the end date for project 3 is shifted one day later because the holiday takes place on one of the working days before the end date.
The following calendar shows the start and end date for project 3 and shows that the holiday changes the end date of the project by one day.
A calendar that shows the start and end date of project 3 with a holiday on May 18
Dataset
The term dataset is sometimes synonymous with table. It can refer to the original source table, the table after undergoing transformations, or the fact and dimension tables in a data mart.
It can also refer to a logical table, where there are several instance tables and views:
Current data
History, which holds previous versions of the table
A preceding load is a script construct that allows you to load from the following LOAD or SELECT statement without specifying that source. Preceding loads are often faster than resident loads.
A field contains values, loaded from a data source. At a basic level, a field corresponds to a column in a table. Fields are used to create dimensions and measures in visualizations.
A Qlik Sense or QlikView app: Apps are task-specific, purpose-built applications. Apps contain data loaded from data sources that is interpreted through visualizations.
The Qlik Sense Mobile app: A mobile app for iOS and Android devices. In the mobile app, you connect to and interact with your cloud data. You can work with your available apps.
A measure is a calculation base on one ore more aggregations. For example, the sum of sales is a single aggregation, while the sum of sales divided by the count of customers is a measure based on two aggregations.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. The information does not usually directly identify you, but it makes the site work as you expect it to and can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
Privacy & Cookie Notice
Manage Consent Preferences
Strictly Necessary Cookies
Always Active
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work.
Functional Cookies
These cookies enable the website to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies, then some or all of these services may not function properly. These cookies do not typically store personal information enabling us to identify you, but are based on uniquely identifying your browser and internet device.
Performance Cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site and make it easier to navigate. For example, they help us to know which pages are the most and least popular and see how visitors move around the site. When analyzing this data it is typically done on an aggregated (anonymous) basis.
Advertising Cookies
These cookies may be set through our site by our advertising partners to build a profile of your interests and show you relevant advertisements on other sites. They do not typically store personal information enabling us to identify you, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less relevant advertising.