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

Week

Hi Experts,

I have one column data  like ....

Day

01 mar

02mar

03 mar

04mar

05 mar

06 mar

07 mar

08 mar

09 mar

10 mar

11 mar

12 mar

13 mar

14 mar

15 mar

16 mar...........................


Here  i need week numbers.

1 Solution

Accepted Solutions
tyagishaila
Specialist
Specialist

Try it,

Test:

Load *,

Left(Day,2) as D,

right(Day,3) as M,

year(Today()) as Y

Inline [

Day

01 mar

02mar

03 mar

04mar

05 mar

06 mar

07 mar

08 mar

09 mar

10 mar

11 mar

12 mar

13 mar

14 mar

15 mar

];

Load *,

Makedate(Y, Month(Date#(M, 'MMM')), D) as Date1

Resident Test;

Drop Table Test;


in Expression: Week(Date1)

View solution in original post

16 Replies
oknotsen
Master III
Master III

Convert the data to actual dates. Once done, use the week() function to generate an extra field that contains the week number.

To convert to date, use the date#() function.

May you live in interesting times!
MarcoWedel

‌and what about the year?

Not applicable
Author

Hi Marco Wedel,

In my data year is not there.

amit_saini
Master III
Master III

Hi,

Once you are having DATE field in Data model , simply write script below to get Month, Week , Year out of it.

LOAD

DATE,

Year(DATE) as YEAR,

Month(DATE) as MONTH,

Week(DATE) as WEEK,

WeekDay(DATE) as WEEKDAY,

Day(DATE) as DAY,

From

.....

Thanks,

AS

Not applicable
Author

Hi AS,

I don't have DATE field  . I have only Day field

Chanty4u
MVP
MVP

tyagishaila
Specialist
Specialist

Try it,

Test:

Load *,

Left(Day,2) as D,

right(Day,3) as M,

year(Today()) as Y

Inline [

Day

01 mar

02mar

03 mar

04mar

05 mar

06 mar

07 mar

08 mar

09 mar

10 mar

11 mar

12 mar

13 mar

14 mar

15 mar

];

Load *,

Makedate(Y, Month(Date#(M, 'MMM')), D) as Date1

Resident Test;

Drop Table Test;


in Expression: Week(Date1)

tyagishaila
Specialist
Specialist

Or by using this You can make script more simple,

Test:

Load *,

Makedate(year(Today()), Month(Date#(right(Day,3), 'MMM')), Left(Day,2)) as Date1

Inline [

Day

01 mar

02mar

03 mar

04mar

05 mar

06 mar

07 mar

08 mar

09 mar

10 mar

11 mar

12 mar

13 mar

14 mar

15 mar

];

Cheers

agustinbobba
Partner - Creator
Partner - Creator

Try this!

Days:

LOAD * INLINE [

    Day

    3/1/2015

    3/2/2015

    3/3/2015

    3/4/2015

    3/5/2015

    3/6/2015

    3/7/2015

    3/8/2015

    3/9/2015

    3/10/2015

    3/11/2015

];

Weeks:

LOAD

  Week(Day) AS Week,

  WeekName(Day) AS WeekName

Resident Days;

2016-03-29_15-32-43.png