Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
sorrakis01
Specialist
Specialist

WEEK NUMBER IN MONTH

Hi,

I'm using a calculated dimension to Know the number of week in the month.

=if(month(weekend(Fecha))= month(Fecha),Round(div(day(WeekEnd(Fecha)),7)),Round(div(day(Weekend(Fecha,-1)),7))+1)+1

It's works well except the months who start on Monday.

Example: 01/09/2014 returns week 2. (7/7 = 1 +1) = 2

I think that a possibbility it's weekday(MonthStart(Fecha)) = 'lun' (monday) then don't sum 1 but i can't solve it on the sequence.

Any idea to solve it?

Thanks!

JAG

1 Solution

Accepted Solutions
rubenmarin

Hola Jordi,

Podrías probar con Ceil((Day(Fecha)+WeekDay(MonthStart(Fecha)))/7)

View solution in original post

12 Replies
Not applicable

Jordi tal vez no entiendo muy bien la pregunta pero yo las saco asi:

'Semana'&Ceil(Day(Fecha)/7) as  SemanaDelMes

Not applicable

Try like below:

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

or check below:

http://community.qlik.com/blogs/qlikviewdesignblog/2014/01/27/week-numbers

Thanks,

Singh

sorrakis01
Specialist
Specialist
Author

Hi Alfredo,

My weeks are from Monday to Sunday

Thanks for the answer but your exemple don't works because for example 30/06/2014 (in your sequence is week number 5) and for me this day is week number 6).

Thanks

ecolomer
Master II
Master II

Un ejemplo

p01.png

sorrakis01
Specialist
Specialist
Author

Hi,

Don't works. Thanks for the link

Regards

Not applicable

you can change the forst day of the week in the system variables in exactly this one:

from this:

SET DayNames='Lun;Mar;Mie;Jue;Vie;Sab;Dom';

to this:

SET DayNames='Dom;Lun;Mar;Mie;Jue;Vie;Sab';

sorrakis01
Specialist
Specialist
Author

Hola Enrique,

Gracias por el ejemplo pero no veo por ningún lado que me indique el número de semana dentro del mes.

Subo un ejemplo:

Meses.jpg

Saludos,

rubenmarin

Hola Jordi,

Podrías probar con Ceil((Day(Fecha)+WeekDay(MonthStart(Fecha)))/7)

ecolomer
Master II
Master II

Hola Jordi,

Si, vuelve a bajar el fichero y en la última pestaña lo tienes