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: 
renjithpl
Specialist
Specialist

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
jonathandienst
Partner - Champion III
Partner - Champion III

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

View solution in original post

4 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

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
Specialist
Specialist
Author

hey dienst thanks for the solution.

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

Regards

ren

jonathandienst
Partner - Champion III
Partner - Champion III

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
renjithpl
Specialist
Specialist
Author

yes, when i used a variable it worked.

Thanks a lot.