Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
neha_sri
Creator III
Creator III

find week number from month and year

Hi,

I have Month and year column with me,Can I find week from available month and year,,

Thanks in anticipation

5 Replies
JonnyPoole
Former Employee
Former Employee

you can. you would use makedate() or date#  to create an expression that combines month and year into a single field, and then use the week() function to extract the week from the results of makedate() or date# function.

but the exact syntax will depend on your data that holds the month and year.  Can you share an example ?

MK_QSL
MVP
MVP

You can get but may be the max week number and min week number for that particular month and year...

neha_sri
Creator III
Creator III
Author

Yes...But I want all the weeks falling in that month

MK_QSL
MVP
MVP

T1:

Load

  MakeDate(2014,Month,1) as MonthStart,

  MonthEnd(MakeDate(2014,Month,1)) as MonthEnd,

  Month,

  2014 as Year

Inline

[

  Month

  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11

  12

];

NoConcatenate

Load

  *,

  Week(Date) as Week;

Load

  MonthStart,

  Date(MonthStart + IterNo() + 1) as Date,

  MonthEnd,

  Month,

  Year

Resident T1

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

Drop Table T1;

===================

Replace 2014 with Year in your script...

MarcoWedel

Hi,

maybe you could use a calendar table created by the script to precalculate all possible year/month/week name combinations during the relevant time period.

e.g. like this:

tabCalendar:

LOAD *,

    Day(Date) as Day,

    WeekDay(Date) as WeekDay,  

    Week(Date) as Week,

    WeekName(Date) as WeekName,

    Month(Date) as Month,

    MonthName(Date) as MonthName,

    QuarterName(Date) as QuarterName,

    Year(Date) as Year,

    WeekYear(Date) as WeekYear;

LOAD Date(Date#('01/01/2005', 'MM/DD/YYYY')+IterNo()-1) as Date

AutoGenerate 1

While Date#('01/01/2005', 'MM/DD/YYYY')+IterNo()-1 <= Today();

QlikCommunity_Thread_130647_Pic1.JPG.jpg

QlikCommunity_Thread_130647_Pic3.JPG.jpg

QlikCommunity_Thread_130647_Pic4.JPG.jpg

QlikCommunity_Thread_130647_Pic2.JPG.jpg

hope this helps

regards

Marco