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

Sorting dual numbers

Hi

I have a list box containing dual numbers, they are currently not sorted from smallest to largest.

2014-12-12_11-20-59.png

I would like it to be :

3-9

10-16

17-23

24-30

How can I do this?

1 Solution

Accepted Solutions
MarcoWedel

Your expression does not create dual values, to do so, you could use:


Dual(

if( month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , day(WeekStart( RE_DAY) ))
&' - '&
if( month(WeekEnd( RE_DAY) )<> month( RE_DAY), day(RE_DAY) , day(WeekEnd( RE_DAY) )),

if( month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , day(WeekStart( RE_DAY) ))

)

AS Weeks;



Using ths expression instead, you can simply sort numerically.


hope this helps


regards


Marco

View solution in original post

9 Replies
tresesco
MVP
MVP

If the are really dual values, the sort should have worked numerically. Can you share a sample qvw?

francoiscave
Partner - Creator III
Partner - Creator III

Hi Tumelo,

You can create the Week number in your script and then, in your Weeks filter order by expression based on your new field.

François

Not applicable
Author


This is the script I use to get the Week values

if( month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , day(WeekStart( RE_DAY) ))
&' - '&
if( month(WeekEnd( RE_DAY) )<> month( RE_DAY), day(RE_DAY) , day(WeekEnd( RE_DAY) )) AS Weeks;

Not applicable
Author

Hi

You can create a number to relate to the weeks in the script which you can then use in the listbox to sort your week buckets by

Rgds

Not applicable
Author

I tried to do that but some weeks were having the same numbers with different month days.

I wanted it to be like

3-9 Week1

10-16 Week2

17-23 Week3

24-30 Week4 for each month

How can I do this?

Not applicable
Author

Hi Tumelo, Whats in your field named: RE_DAY ?  You could sort that if its the underlying day in the listbox>sort tab - otherwise could you send me an example of the above screenshot and I'll create a little lookup table for you.

Not applicable
Author

RE-DAY is a date field

MarcoWedel

Your expression does not create dual values, to do so, you could use:


Dual(

if( month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , day(WeekStart( RE_DAY) ))
&' - '&
if( month(WeekEnd( RE_DAY) )<> month( RE_DAY), day(RE_DAY) , day(WeekEnd( RE_DAY) )),

if( month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , day(WeekStart( RE_DAY) ))

)

AS Weeks;



Using ths expression instead, you can simply sort numerically.


hope this helps


regards


Marco

francoiscave
Partner - Creator III
Partner - Creator III

Tumelo,

Use the WeekName(Re_DAY) as WeekNo function in your script in the same Load statement that youor field Weeks.

Then, you could sort by WeekNo in your listbox (sort Tab).

François