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: 
Qlik_Ajanta_Pharma
Contributor
Contributor

Week bucket with date field

Hi,

How to make Week bucket with date field from Monday to Sunday

example if 1/9/2025 then 1/9/2025 - 7/9/2025 this should my output

please check my master calender

SP_Min_Max_COMMERCIAL:

Load

Min("GRN Date") as SP_MINDATE,

Max("GRN Date") as SP_MAXDATE

Resident Open_GRN;


Let vSPMinDate = Peek('SP_MINDATE',0,'SP_Min_Max_COMMERCIAL');

Let vSPMaxDate = Peek('SP_MAXDATE',0,'SP_Min_Max_COMMERCIAL');

Drop Table SP_Min_Max_COMMERCIAL;

 

SP_TEMP_CALENDAR:

Load
$(vSPMinDate) + IterNo() - 1 as "GRN Date",

Date($(vSPMinDate) + IterNo() - 1) as PO_DATE_FORMATTED
AUTOGENERATE 1
WHILE $(vSPMinDate) + IterNo() - 1 <= $(vSPMaxDate);

 

SP_MASTER_CALENDAR:

Load *,
"GRN Date"&' - '& SP_MONTHYEAR as SP_DMY;

LOAD
Date("GRN Date",'DD-MM-YYYY') as "GRN Date",
Year("GRN Date") as SP_YEAR,
Month("GRN Date") as SP_MONTH,
MonthName("GRN Date") as SP_MONTHYEAR,
//Date(Date#(PO_DATE, 'MMM-YYYY'), 'MMM-YYYY') AS SP_MONTHYEAR_NUM,
Day("GRN Date") as SP_DAY,
YearToDate("GRN Date") as SP_YTD,
Week("GRN Date") as SP_WEEK,
WeekName("GRN Date") as SP_WEEK_Name,
WeekYear("GRN Date") as SP_WEEK_Year
Resident SP_TEMP_CALENDAR;

DROP Table SP_TEMP_CALENDAR;

Labels (1)
1 Solution

Accepted Solutions
Chanty4u
MVP
MVP

Try this 

WeekStart("GRN Date", 0, 0) as SP_WEEK_START, 

WeekEnd("GRN Date", 0, 0) as SP_WEEK_END, 

Date(WeekStart("GRN Date", 0, 0)) & ' - ' & Date(WeekEnd("GRN Date", 0, 0)) as SP_WEEK_BUCKET

 

View solution in original post

2 Replies
howdash
Creator II
Creator II

You’ll need to use the WeekStart() and WeekEnd() functions for that. Something like this:

WeekStart([GRN Date], 0, 0) & ‘ - ‘ & WeekEnd([GRN Date], 0, 0) as [Week bucket]

Chanty4u
MVP
MVP

Try this 

WeekStart("GRN Date", 0, 0) as SP_WEEK_START, 

WeekEnd("GRN Date", 0, 0) as SP_WEEK_END, 

Date(WeekStart("GRN Date", 0, 0)) & ' - ' & Date(WeekEnd("GRN Date", 0, 0)) as SP_WEEK_BUCKET