Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

yanivbm88
Contributor

Set work week in 'Lastworkdate' function

I am using the lastworkdate function, which should return the date once adding x working days to the starting date, for example:

  • lastworkdate ('2007-02-19', 9) returns '2007-03-01'


How would you set which weekdays should be referred as working days?

I understood that the default is Monday-Friday, but how can I change it to Sunday-Thursday?

I tried modifying FirstWeekDay attribute with no success

1 Solution

Accepted Solutions
yanivbm88
Contributor

Re: Set work week in 'Lastworkdate' function

Actually, deducting one day from LASTWORKDATE output and adding one day to starting date will give the desired output.

lastworkdate (START_DATE+1, DAYS_AMOUNT)-1

6 Replies
martinpohl
Valued Contributor II

Re: Set work week in 'Lastworkdate' function

Hello Yaniv,

there are no other options in lastworkdate than holidays.

One solution:

Create your own workingday calendar (e.g, beginning at 1/1/2000 each day get the option working day yes/no, kumulate all days until 12/21/2020 (for example could be working day 2,219)

Than apply to each date the working day and apply again the lowest date to this day so you will get the last working day.

Regards

dan_sullivan
Contributor II

Re: Set work week in 'Lastworkdate' function

SET FirstWeekDay=5   // this will set Saturday as the first day of the week in your script declarations

Then you can use WEEKEND formula to always get the Friday date.

WEEKEND('2007-02-19') should return the friday you are looking for

dan_sullivan
Contributor II

Re: Set work week in 'Lastworkdate' function

Did this work you?  Please update the thread if it did.

yanivbm88
Contributor

Re: Set work week in 'Lastworkdate' function

What I requested was to add X amount of working days to a certain date (as in LASTWORKDATE formula), based on Sunday-Thursday work-week,  .

I assume this is not possible with LASTWORKDATE, based on the comment of martinpohl‌.

yanivbm88
Contributor

Re: Set work week in 'Lastworkdate' function

Hi Martin,

This can be a solution, but isn't there any built-in formula that allows working-week modification?

yanivbm88
Contributor

Re: Set work week in 'Lastworkdate' function

Actually, deducting one day from LASTWORKDATE output and adding one day to starting date will give the desired output.

lastworkdate (START_DATE+1, DAYS_AMOUNT)-1

Community Browser