Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
sireesha1
Contributor II
Contributor II

one week occurs in two months how to handle this in qlik sense?

please help with scenario,

if user selected a month  exclude the dates flowing in other month week

Labels (1)
6 Replies
vinieme12
Champion III
Champion III

As below

 

let vStartDate= '2021-01-01';
let vEndDate= '2021-12-31';


temp_Calendar:
Load
Date
,MonthName(Date) as CalendarMonth
,Week(Date) as IsoWeek
;
Load
date(date#('$(vStartDate)','YYYY-MM-DD')+Iterno()-1) as Date
AutoGenerate 1
while date#('$(vStartDate)','YYYY-MM-DD') +Iterno()-1 <= date#('$(vEndDate)','YYYY-MM-DD');

Left Join (temp_Calendar)
Load IsoWeek,Mode(CalendarMonth) as WeekMonth
Resident temp_Calendar
Group by IsoWeek
;

Calendar:
Load
*
,if(CalendarMonth=WeekMonth,1,0) as flag_WeekInSameMonth
Resident temp_Calendar;
drop table temp_Calendar;

 

then use flag_WeekInSameMonth in set analysis

 

sum({<flag_WeekInSameMonth ={1}>}Amount)

 

 

 

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

thank u for the reply,if the user selected a month it has to show the
result for dates that flowing in another month week also bult exclude the
date that are in another month
vinieme12
Champion III
Champion III

can you explain by way of example for clarity

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

Hi vinieme12,
we are calculate the time sheet submission% on monthly basis,we got
the timesheet data once per a week not daily basis. when user select a
month the dates should not flow into another weekcode month.it
should exclude the dates of another month in that weekcode.
for example
if take the feb-2022 28th date is flowing in march-2022 first week,we must
exclude the march dates flowing dates and calculate the upto 28th in that
week
i hope the issue will be understand by you
Thanks and regards
vinieme12
Champion III
Champion III

this is exactly what the flag created in above script does, have you tried it yet?

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

Hi vinie
i had been tried your script,if week over flag=1, then we have
calculate how many days are flowing into next month weekcode and those days
are not part of the next month.
for example for february 2 days are flowing for march 4 days are
flowing,for april 5 days are flowing,that means we have to calculate for
each month using if condition.
in set analysis is it possible to do that
Thanks and Regards