Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

Week start

Hi,

How to get week start as Sunday>Below is the expression used to derive week

if(month(weekend(new_order_date))= month(new_order_date),div(day(WeekEnd(new_order_date)),7),div(day(Weekend(new_order_date,-1)),7)+1) as Week

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try setting an offset to make sunday the first day of the week:

if(month(weekend(new_order_date,0,6))= month(new_order_date),div(day(WeekEnd(new_order_date,0,6)),7),div(day(Weekend(new_order_date,-1,6)),7)+1) as Week


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Gysbert_Wassenaar

Try setting an offset to make sunday the first day of the week:

if(month(weekend(new_order_date,0,6))= month(new_order_date),div(day(WeekEnd(new_order_date,0,6)),7),div(day(Weekend(new_order_date,-1,6)),7)+1) as Week


talk is cheap, supply exceeds demand
nareshthavidishetty
Creator III
Creator III
Author

Hi,

But it gives as below ,which indicates 6 weeks in an month.

Untitled.png

Thanks..

nareshthavidishetty
Creator III
Creator III
Author

Hi,


I have removed +1 in above expression and now its fine.

Here it gives week numbers but i need to show as Week1,week2....week4.


I have used the below,which won't work


'Week' & if(month(weekend(new_order_date,0,6))= month(new_order_date),div(day(WeekEnd(new_order_date,0,6)),7),div(day(Weekend(new_order_date,-1,6)),7)) as WeekNumber

Thanks

nareshthavidishetty
Creator III
Creator III
Author

Hi,


I have removed +1 in above expression and now its fine.

Here it gives week numbers but i need to show as Week1,week2....week4.


I have used the below,which won't work


'Week' & if(month(weekend(new_order_date,0,6))= month(new_order_date),div(day(WeekEnd(new_order_date,0,6)),7),div(day(Weekend(new_order_date,-1,6)),7)) as WeekNumber

Thanks


nareshthavidishetty
Creator III
Creator III
Author

Hi,

The below logic gaves as week0,week1....week4 but i need to show week1..week2.....week5

'Week' & if(month(weekend(new_order_date,0,6))= month(new_order_date),div(day(WeekEnd(new_order_date,0,6)),7),div(day(Weekend(new_order_date,-1,6)),7)) as WeekNumber

Thanks

Gysbert_Wassenaar

You're welcome. If the problem is solved now please mark this discussion as answered.


talk is cheap, supply exceeds demand