Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

renjithpl
Valued Contributor

Week number starting from 1 from a random date

Hi All,

I have a date field starting from 26-Nov-2009 . . . . etc.

I have a list box with field called "Week" but it shows actual week number from 48 49 50. . . etc

I want it as 1 2 3 .

How would I achieve this. ? Thanks in Advance

Ren

1 Solution

Accepted Solutions
MVP
MVP

Week number starting from 1 from a random date

Hi

Sure. If the week numbers are based on a field or variable called baseDate:

=Week - week(baseDate) + If(Week >= week(baseDate), 1, 52)

(refactored slightly to reduce the calculations, but mathematically the same).

Jonathan


Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
4 Replies
MVP
MVP

Week number starting from 1 from a random date

Hi

Assuming your start date is fixed, how about

=If(Week >=48, Week - 47, Week + 4)

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
renjithpl
Valued Contributor

Week number starting from 1 from a random date

hey dienst thanks for the solution.

your coding works perfectly, but is there any solution, if my date is not fixed.

Regards

ren

MVP
MVP

Week number starting from 1 from a random date

Hi

Sure. If the week numbers are based on a field or variable called baseDate:

=Week - week(baseDate) + If(Week >= week(baseDate), 1, 52)

(refactored slightly to reduce the calculations, but mathematically the same).

Jonathan


Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Highlighted
renjithpl
Valued Contributor

Week number starting from 1 from a random date

yes, when i used a variable it worked.

Thanks a lot.