Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
mazacini
Creator III
Creator III

WeekName formats

Hi

I have created a variable

LET vRepWeek = WeekName(Today());

It creates a value 2015/38 for the current week.

I am trying to compare this date to a LastSaleWeek created in my script

WeekName(Max(WeekName)) as LastSaleWeek,

I am trying to compute the difference between these two values.

Problem is that the VRepWeek is being interpreted by Qlikview as a number 53.0262 ie 2015 divided by 38 (2015/38).

As you can see, the two fields have different formats.

Any suggestions?

WeekName format.PNG

1 Solution

Accepted Solutions
sasiparupudi1
Master III
Master III

Try

=WeekName(Today(1))-  weekname(makedate(SubField('2014/02','/',1)),SubField('2014/02','/',2))

hth

Sasi

View solution in original post

7 Replies
alexandros17
Partner - Champion III
Partner - Champion III

when I manage weeks and Year I use to write expression like:

WeekYear(myDate)*100 + Week(myDate)

this expression returns the number 201538 that can be managed easily ...

mazacini
Creator III
Creator III
Author

Thanks Alessandro.

I actually do something similar in Excel.

But us 201538 a number?

How would this work across multiple years? If I wanted to establish the interval between 201438 and 201505, how would this compute?

Regards

Joe

alexandros17
Partner - Champion III
Partner - Champion III

Only an idea ... use the starting dates of weeks then make a difference between 2 dates and divide by 7:

Suppose that the date (DT1) 17 Sep 2014 gives you the week 201438 and (DT2) 28 Jan 2015 is the 201505 then

(WeekStart(DT2) - WeekStart(DT1))/7 returns the number of weeks between the two.

let me know

tresesco
MVP
MVP

Possibly you are using $ expansion to that variable which is then converting the texual presentation to evaluated number. Try without $ with variable.

sasiparupudi1
Master III
Master III

Try

=WeekName(Today(1))-  weekname(makedate(SubField('2014/02','/',1)),SubField('2014/02','/',2))

hth

Sasi

mazacini
Creator III
Creator III
Author

Hi

Thank you for your response.

When I drop the dollar expansion, the script does not seem to recognise the variable.

Is there a particular syntax I should be using?

Regards

Joe

tresesco
MVP
MVP

Could you share your qvw sample?