Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
stabben23
Honored Contributor

YearWeek -1

Hi,

I have a YearWeek field 201401 (YYYYWW) if I want to step 1 week back i'll get 201400.

I have test with two different:

Dual(WeekYear(Date)&'W'&num(Week(Date),00),WeekYear(Date)&num(Week(Date),00)) as [Year Week],

num(WeekYear(Date)&num(Week(Date),00)) as [Year Week Num],

These are numeric and thats why I get 201400, but how to get the YerWeek field as a date so it will show 201352?

I will use the field in a set analysis.

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: YearWeek -1

Hi,

Try this

=Replace(WeekName(Date#(20140101, 'YYYYMMDD'), -1), '/', '')

Regards,

Jagan.

7 Replies
MVP
MVP

Re: YearWeek -1

WeekName(MakeWeekDate(Left('201401',4), Right('201401',2)),-1)                          //'-1'  refers one week back

stabben23
Honored Contributor

Re: YearWeek -1

Hi,

a little bit closer, if we use a date like 20140101 how can we format this to a yearweek that is non numeric?

Re: YearWeek -1

Try something like this

=Replace(WeekName(Date#(20140101, 'YYYYMMDD')), '/', '')

Not applicable

Re: YearWeek -1

One solution could be to add an "index" for the YearWeek in your time table with AutoNumber:

AutoNumber(YearWeek, 'YearWeekID') as [YearWeekID];

Then you can just do simple integer calculating on this "index", e.g. the YearWeeID.

You just need to get the ID of your actual YearWeek in a variable.

Hope it helps

stabben23
Honored Contributor

Re: YearWeek -1

That will give me 201400 if I add -1

MVP
MVP

Re: YearWeek -1

Hi,

Try this

=Replace(WeekName(Date#(20140101, 'YYYYMMDD'), -1), '/', '')

Regards,

Jagan.

stabben23
Honored Contributor

Re: YearWeek -1

,

Thank you guys.

Community Browser