Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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 !

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Monthly week number !

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

6 Replies
fosuzuki
Valued Contributor II

Re: Monthly week number !

maybe you can use:

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

chematos
Valued Contributor II

Re: Monthly week number !

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

Not applicable

Re: Monthly week number !

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

jaguilera
New Contributor II

Re: Monthly week number !

fantastic solution!

thanks

philmywallet
New Contributor III

Re: Monthly week number !

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

philmywallet
New Contributor III

Re: Monthly week number !


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,

Community Browser