Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
grakeshqvd
Contributor III
Contributor III

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

Hello,

 

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

Like,

 

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.

 

 

 

Thanks, 

1 Reply
edwin
Master II
Master II

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