Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

How to change the variable value on 6th business day every month



Need to change the variable value on 6th business day every month. 



Have one variable like vMMMYYYY=  (Current Month - 1).

that is For Jan 2021 the value in variable is DEC2020 and the same for Feb 2021 the value in variable is JAN2021 and so on. 

But, We need to change the value only on 6th business day every month. 

For Jan 2021 month, 6th working day 11-01-2021. So, from that date onwards only variable value change that is DEC2020 and For Jan 1st to Jan 10th 2021, the variable value is Nov-2020 only. 

When we comes 6th business day (Jan11 th 2021)  or after only variable value needs to change to DEC2020.





1 Reply
Specialist III
Specialist III

first there needs to be a flag that indicates if a date is a workday or not.  some companies give the whole week of Dec 25 to Jan 1 to employees as off days, some dont.  you can count that field to know the number of days between the start of the month and today to determine if the 6 days have lapsed.  then your variable could be:

=if(sum({<date={">=$(=monthstart(today()))<=$(=date(today()))"}>}isworkday)<6, addmonths(monthstart(today()),-2), addmonths(monthstart(today()),-1))

if six work days havent lapsed use 2 months back else use 1 month back.  isworkday is your field that determines if it is a workday (=1) or not (=0) so you can count it