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: 
Bart_Breekveldt
Contributor III
Contributor III

Rolling Weeks Sorting

Dear Community,

I've a problem. I've calculated rolling weeks a year back (52) with this formula:

=IF(WeekYear(Today())=WeeKYear(Timestamp) AND Week(Timestamp)<Week(Today()),'W-'&Week(Order.Leverdatum),
IF(WeekYear(Timestamp)=WeekYear(Today())-1 AND Week(Timestamp)>=Week(Today()),'W-'&Week(Timestamp)&' (`'&Right(WeekYear(Timestamp),2)&')'))

For all the weeks in this year, I didn't add the year in brakes, for those from last year I did. With the following result / lay-out:

Qlik Week Sorting.PNG

However my preferrerd result is W-49, W-48, W-47 ... W-52 ('18), W-51 ('18), W-50 ('18) (newest weeks first). When I want to sort by expression date or weekyear, the sorting didn't react.

 

How can I sort these rolling weeks in the preferred order?

Thanks in advance.

Labels (2)
1 Solution

Accepted Solutions
andoryuu
Creator III
Creator III

It would appear that what you're looking for is this:

Dates.jpg

If so, I've adjusted your code to be the following where "DateField" is to be substituted with your value (perhaps "Order.Leverdatum"?)

=IF(WeeKYear(DateField)<WeekYear(Today()),'W-'&Week(DateField)&' (`'&Right(WeekYear(DateField),2)&')','W-'&Week(DateField))

 

Sample attached.

View solution in original post

1 Reply
andoryuu
Creator III
Creator III

It would appear that what you're looking for is this:

Dates.jpg

If so, I've adjusted your code to be the following where "DateField" is to be substituted with your value (perhaps "Order.Leverdatum"?)

=IF(WeeKYear(DateField)<WeekYear(Today()),'W-'&Week(DateField)&' (`'&Right(WeekYear(DateField),2)&')','W-'&Week(DateField))

 

Sample attached.