Announcements
Product Release Webinar: Qlik Insider airing December 6! REGISTER TODAY!
cancel
Showing results for
Did you mean:
Not applicable

## Week of the month

Hi,

I wanted to create another field which is will define as number of the Week for the Date.  The number of the week should will start from 1 and will end with 4 or 5 for the particular month.  Please let me know the expression.

Week NumberRangeDate
11 - 6 Nov 2011
27 - 13 Nov 2011
314 - 20 Nov 2011
421 - 27 Nov 2011
528 - 30 Nov 2011
11 - 4 Dec 2011
25 - 11 Dec 2011
312 - 18 Dec 2011
419 - 25 Dec 2011
526 - 31 Dec 2011

1 Solution

Accepted Solutions
MVP

Try something like

,if(month(weekend(Date))= month(Date),div(WeekendDay,7),div(day(Weekend(Date,-1)),7)+1)+1 as Weeknumber

;

,day(WeekEnd(Date)) as WeekendDay

,day(Date) as DayOfMonth

,weekday(Date) as Weekday

;

date(makedate(2011,1,1)+recno()-1) as Date

AUTOGENERATE 365

;

4 Replies
Partner - Creator II
MVP

Try something like

,if(month(weekend(Date))= month(Date),div(WeekendDay,7),div(day(Weekend(Date,-1)),7)+1)+1 as Weeknumber

;

,day(WeekEnd(Date)) as WeekendDay

,day(Date) as DayOfMonth

,weekday(Date) as Weekday

;

date(makedate(2011,1,1)+recno()-1) as Date

AUTOGENERATE 365

;

Contributor III

Hi,

In that case if Weekend is 07th date of everymonth. Then it will shows 01st to 6th date as 2nd week which is wrong. It should show 1st week. Please help on this.

Example : May Month Weekstart from 01-May-2011 and ends on 07-May-2011. So this is weekno 1 and 08-May-2011 to 14-May-2011 is 2nd week but here it is showing wrong. Please check and revert

Regards,

Sakthivel.S

Contributor III

Hi

This Works fine.

if((week(Date) - week(monthstart(Date)) + 1)<1,1,(week(Date) - week(monthstart(Date)) + 1))

Regards,

Sakthivel.S

Community Browser