Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
QlickySense
Creator
Creator

Order of weekdates with string

Hello,

I've created a dates to look like 

Week(MyDate) & ' ' & 'Week' & Chr(13) & Year(MyDate) 

However because I add 'Week' it becomes string and loses its order (without it its fine). However client really want its with "Week" or "W"

Any ideas?

Labels (3)
7 Replies
Vegar
MVP
MVP

You can create a dual of your field to solve this.

Try to create your field like this:

Dual(Week(MyDate) & ' ' & 'Week' & Chr(13) & Year(MyDate),monthname(MyDate))

 

QlickySense
Creator
Creator
Author

Hi,

unfortunately It didnt work

 

Vegar
MVP
MVP

I am concerned about the calculation of your week-year. In some situations the calendar year is not the same as the week's year.

Week(MyDate) & ' ' & 'Week' & Chr(13) & Year(MyDate)

Eg:  January 1th 2021 is in Week 53 2020, but your calculation will return the year 2021. 

It is better to avoid using Year() and rather use the WeekYear() function when handling weeks. Like I've done below.

Week(MyDate) & ' ' & 'Week' & Chr(13) & WeekYear(MyDate)

QlickySense
Creator
Creator
Author

Thanks, I'll apply that. However still don't resolved sorting problem, with WeekYear it is the same, unfortunately

Vegar
MVP
MVP

We misunderstand each other. I assumed you would use my suggestion to define your field in the script, replacing your current field.

QlickySense
Creator
Creator
Author

It converts nicely, but my problem is that if I get this field in X-axis it appears in random order like 4 Week 2020 and then 52 Week 2020, I'd like to order them by year and week

Vegar
MVP
MVP

Check the object properties that your chart is ordered by your dual value dimension and that the sort order of your dimension is set to numeric sorting.