Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Jay587
Creator

Segregate the data on Weekly basis

Hi Team,

There is a scenario where ,if month changes in a middle of week, need to show the results on a monthly level ? 

Below is the example.

I have the data of year 2025 and selected the January month but when i select the week it's showing only 4 weeks from W2 to W5 and W1 is ignoring when the week is between in the Dec and Jan months.

Jay587_1-1727179816805.png

 

How to segregate the data on weekly basis when we select any month and it should show complete weeks of that month.

Please help me how to achieve this on script or UI level.

Thanks in advance.

 

1 Reply
zar
Employee

Did you tried create the calendar like there: https://qlikviewcookbook.com/2015/05/better-calendar-scripts/

You probably would like have a custom field:  Year(TempDate)&' '&'W'&week(TempDate) As Week 

Full script used:

DATA:
LOAD
Date#(OrderDate,'D/M/YYYY')ASOrderDate
;
LOAD * INLINE [
OrderDate
1/1/2024
1/12/2025
]
;
 
 
MasterCalendar: 
Load 
 TempDate AS OrderDate, 
//  week(TempDate) As Week, 
 Year(TempDate) As Year, 
 Month(TempDate) As Month, 
 Day(TempDate) As Day, 
 'Q' & ceil(month(TempDate) / 3) AS Quarter, 
 Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear, 
 WeekDay(TempDate) as WeekDay ,
 Year(TempDate)&' '&'W'&week(TempDate) As Week
;
 
//=== Generate a temp table of dates === 
LOAD 
 date(mindate + IterNo()) AS TempDate
 ,maxdate // Used in InYearToDate() above, but not kept 
WHILE mindate + IterNo() <= maxdate;
 
//=== Get min/max dates from Field ===/
LOAD
 min(FieldValue('OrderDate', recno()))-1 as mindate,
 max(FieldValue('OrderDate', recno())) as maxdate
AUTOGENERATE FieldValueCount('OrderDate');

 

Result:

Captura de pantalla 2024-10-08 a las 20.39.25.png