Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Monthly week number !

I've was using the week() function, but that function returns me the week number of the year.

But I've need the monthly week number.

I don't need the complete week, can be incomplete.

Example:

MondayTuesdayWednesdayThursdayFrydaySaturdaySunday                          





0102
Week number 1
03040506070809
Week number 2
10111213141516
Week number 3
17181920212223
Week number 4
24252627282930
Week number 5

Any suggestions ?

Tks !

1 Solution

Accepted Solutions
Not applicable
Author

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

View solution in original post

7 Replies
fosuzuki
Partner - Specialist III
Partner - Specialist III

maybe you can use:

=week(date) - week(monthstart(date)) + 1

chematos
Specialist II
Specialist II

= week(date) - week(monthend(addmonths(date,-1)))

Not applicable
Author

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

Anonymous
Not applicable
Author

fantastic solution!

thanks

Anonymous
Not applicable
Author

Hi

Just tried this and it shows that 1st July 2013 is in week 2, yet it is actually week 1.

Could you clarify.

Thanks

Phil

Anonymous
Not applicable
Author


Had to use this to make it correct .....

 

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

sakthi266
Contributor III
Contributor III

Hi,

   This script fails if Weekend ie is 7th.

Eg. If 01st is Sunday and 7th is saturday and system shows this as 2nd week instead of first week. Check this out and let me know.

Regards, 

Sakthivel.S