Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

mayuridg
Contributor

Monthwise Week

Hello,

I need Monthwise week seperation.

e.g

in Aug month as per calendar, it should display 6 weeks

as Week1, week2 and so on...

So how to do that ?

1 Solution

Accepted Solutions

Re: Monthwise Week

Something like below?


Let vMinDate = Num(YearStart(Today()));

Let vMaxDate = Num(YearEnd(Today()));

Date:

Load

  Date,

  WeekDay(Date) as Day,

  If(Date = MonthStart(Date),1) as Week;

Load

  Date($(vMinDate) + IterNo() - 1) as Date

AutoGenerate 1

While $(vMinDate) + IterNo() - 1 <= $(vMaxDate);

Final:

Load

  Date,

  Month(Date) as Month,

  Year(Date) as Year,

  If(Week=1, Week,

  If(Day = 'Mon', RangeSum(Peek('Week'),1),Peek('Week'))) as Week

Resident Date

Order By Date;

Drop Table Date;

7 Replies
parthakk
Contributor II

Re: Monthwise Week

sorry 6 weeks in Aug month???

Re: Monthwise Week

Something like below?


Let vMinDate = Num(YearStart(Today()));

Let vMaxDate = Num(YearEnd(Today()));

Date:

Load

  Date,

  WeekDay(Date) as Day,

  If(Date = MonthStart(Date),1) as Week;

Load

  Date($(vMinDate) + IterNo() - 1) as Date

AutoGenerate 1

While $(vMinDate) + IterNo() - 1 <= $(vMaxDate);

Final:

Load

  Date,

  Month(Date) as Month,

  Year(Date) as Year,

  If(Week=1, Week,

  If(Day = 'Mon', RangeSum(Peek('Week'),1),Peek('Week'))) as Week

Resident Date

Order By Date;

Drop Table Date;

mayuridg
Contributor

Re: Monthwise Week

Hi,


Thanks for the help.

I have applied same logic in my application but I am getting multiple weeks instead of 6 weeks as per your script.

Please check the attached application as its not worked... please help @ manish !

Thanks in advance,

Mayuri.

Re: Monthwise Week

You have to use WeekNum as your final Week Field... Not Week !

mayuridg
Contributor

Re: Monthwise Week

Hello,

I have also done using week, but still its giving multiple week.

Thanks ,

Mayuri

Re: Monthwise Week

Upload the file after running the script. I am unable to see WeekNum

mayuridg
Contributor

Re: Monthwise Week

Thanks Manish... There was Date Problem

Community Browser