# App Development

Announcements
April 22, 2PM EST: Learn about GeoOperations in Qlik Sense SaaS READ MORE
cancel
Showing results for
Did you mean:
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:

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?

Labels (3)

• ### sorting

1 Solution

Accepted Solutions
Creator III

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

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.

Creator III

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

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.

Tags
Community Browser