Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Week Number from Month

Hi all, i need your expertice help.

It's possible to obtain the week numbers grouping by month from a date?

For example,  today()  is Month=10

I need to obtain one table with:

Week39

Week40

Week41

Week42

Week43

Week44

Is This possible?

Thanks in advenced!!

1 Solution

Accepted Solutions
sunny_talwar

May be something like this:

Table:

LOAD Date(MonthStart(Today()) + IterNo() - 1) as Date,

  Week(MonthStart(Today()) + IterNo() - 1) as WeekNum

AutoGenerate 1

While IterNo() <= (Floor(MonthEnd(Today())) - Floor(MonthStart(Today())) + 1);

Update: Fixed the order of MonthEnd and MonthStart in the while statement

Capture.PNG

View solution in original post

8 Replies
sunny_talwar

So you want to know all the weeks that come in the month of October? Is that the goal? In the script?

Not applicable
Author

yep, but the source is today()

sunny_talwar

May be something like this:

Table:

LOAD Date(MonthStart(Today()) + IterNo() - 1) as Date,

  Week(MonthStart(Today()) + IterNo() - 1) as WeekNum

AutoGenerate 1

While IterNo() <= (Floor(MonthEnd(Today())) - Floor(MonthStart(Today())) + 1);

Update: Fixed the order of MonthEnd and MonthStart in the while statement

Capture.PNG

Not applicable
Author

Thanks Sunny , but does not work, return 0 Rows

sunny_talwar

Sorry, I just updated my code:

Table:

LOAD Date(MonthStart(Today()) + IterNo() - 1) as Date,

  Week(MonthStart(Today()) + IterNo() - 1) as WeekNum

AutoGenerate 1

While IterNo() <= (Floor(MonthEnd(Today())) - Floor(MonthStart(Today())) + 1);

Not applicable
Author

yeeeeeeeeeah!! you are the best!!

Many thanks!!! Works perfectly!!

eromiyasimon
Creator II
Creator II

hi francisco,

you can get a particular week number between two different dates or you can take the current week number for this year,

i have added for current year.

here's the solution

=ceil((Today()-'01/01/2016')/7)

hope this helps

Not applicable
Author

Thanks Simon, the Sunny answer resolved mi issue