# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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
MVP

## Re: Monthwise Week

Something like below?

```Let vMinDate = Num(YearStart(Today()));
Let vMaxDate = Num(YearEnd(Today()));

Date:
Date,
WeekDay(Date) as Day,
If(Date = MonthStart(Date),1) as Week;
Date(\$(vMinDate) + IterNo() - 1) as Date
AutoGenerate 1
While \$(vMinDate) + IterNo() - 1 <= \$(vMaxDate);

Final:
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
Contributor II

## Re: Monthwise Week

sorry 6 weeks in Aug month???

MVP

## Re: Monthwise Week

Something like below?

```Let vMinDate = Num(YearStart(Today()));
Let vMaxDate = Num(YearEnd(Today()));

Date:
Date,
WeekDay(Date) as Day,
If(Date = MonthStart(Date),1) as Week;
Date(\$(vMinDate) + IterNo() - 1) as Date
AutoGenerate 1
While \$(vMinDate) + IterNo() - 1 <= \$(vMaxDate);

Final:
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;
```
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.

Mayuri.

MVP

## Re: Monthwise Week

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

Contributor

## Re: Monthwise Week

Hello,

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

Thanks ,

Mayuri

MVP

## Re: Monthwise Week

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

Contributor

## Re: Monthwise Week

Thanks Manish... There was Date Problem