Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
P_Kale
Creator II
Creator II

How to set variable which will execute report 1 to 15 on 16 th and 1 to 30 / 31 /29 on start of the month

Hi,

My ask is I have to schedule a report which will run on 16th of the month and on 1st or 2nd of  next moth.

on 16th when report will run it holds data for 1 to 15 and when it executed on start of the month then it holds data for entire last month. I have tried it below way where i have set a 3 variables. But facing difficulty in writing in variable where  if day is 16 then last date is 15 and in start of the month last date should be either 30/31 or 29.

1) Let vStartDate = date(floor(monthstart(addmonths(today(),-1))));

2) Let vEndDate = date(floor(monthend(addmonths(today(),-1))));

3) let vSdate = left(date(Today()),2);

Start of the month is very much clear where i can take 1st variable but need help while setting "end date" variable.

below given is the script where i am going to use these variable and need to have variable at '....' place

DayName(PTRNEFF) >= '$(vStartDate)' and DayName(PTRNEFF) <= ........
and date(date#(TRANSACTION_DATE,'YYMMDD'),'DD/MM/YYYY') >= '$(vStartDate)'

Thanks in advance.

Labels (1)
1 Reply
vinieme12
Champion III
Champion III

As below, set variables in a conditional block

 

IF day(today())=1 THEN

//Previous Monthend

let vStartDate = MonthStart(Today(),-1);
let vEndDate =  MonthEnd(Today(),-1);

ElseIF day(today())>=16 THEN

//any day after 16th then; Current month 1st to 15th

let vStartDate = MonthStart(Today());
let vEndDate = Date( MonthStart(Today())+14);

End IF

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.