Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
arixooo123
Creator III
Creator III

how to sort the order of values in a list box manually

hello dears,

I have a list box including the Shamsi Months ( Months in Persian), 

I tested all of the sort options (state,expressions,frequency...) but it does not get sorted as i wanted it to be.

I want to order them as it is in calender, apparently i have to sort them manually. but how?

thank you tabcalendar.png

1 Solution

Accepted Solutions
ashfaq_haseeb
Champion III
Champion III

Hi,

Create a new qvw file and use the below script

load * Inline

[

Month,Year,Amount

فروردین,2013,500

اردیبهشت,2013,500

خرداد,2013,500

تیر,2013,500

مرداد,2013,500

شهریور,2013,500

مهر,2013,500

آبان,2013,500

آذر,2013,500

دی,2013,500

بهمن,2013,500

اسفند,2013,500

فروردین,2014,500

اردیبهشت,2014,600

خرداد,2014,600

تیر,2014,600

مرداد,2014,600

شهریور,2014,600

مهر,2014,600

آبان,2014,600

آذر,2014,600

دی,2014,600

بهمن,2014,600

اسفند,2014,600

]

Save and reload

Now drop your Month Field list box to your front end application.

Right click on month properties sort tab --> Select load order reversed.

Look at capture.jpg image attached.

Or

use the below expression to sort

=Match(Month,'اسفند','بهمن','دی','آذر','آبان','مهر','شهریور','مرداد','تیر','خرداد','اردیبهشت','فروردین') 

Create bar chart with month as dimension and sum(Amount) as expression

Again go to chart properties --> sort tab of chat--> Select load order reversed.

Or

use the below expression to sort

=Match(Month,'اسفند','بهمن','دی','آذر','آبان','مهر','شهریور','مرداد','تیر','خرداد','اردیبهشت','فروردین') 

Look at  final output capture1.jpg

Regards

ASHFAQ

View solution in original post

23 Replies
aveeeeeee7en
Specialist III
Specialist III

Hi arman

In the Sort Options you'll see Expression, Check that Option and paste this Expression Accordingly:

Dual("Your Month Field",match("Your Month Field" ,'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'))

Since, I don't know Shamsi Months, so set accordingly and sort in Ascending or Descending Order.

Suppose, if you want Jan after Mar than do change in Expression Order.

List Box Sort.jpg.jpg

Here, Month is your Shamsi Months Field Name.

Replace Month with your Application Month Field.

Hope that helps.

Regards

Aviral Nag

arixooo123
Creator III
Creator III
Author

Thank You for your answer, what if i use month field as a dimension in a chart?  suppose i want to see the sales trends of year 2013, how can i reorder the month fields there?

aveeeeeee7en
Specialist III
Specialist III

For this case, use the Same Expression.

Dual("Your Month Field",match("Your Month Field" ,'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'))

Here, your Your Month Field is the Dimension Month which you have used in your chart.

Regards

Aviral Nag

arixooo123
Creator III
Creator III
Author

i did what you said for sorting the month list box, but it did not change at all, what do you think might be the reason?

what can i do?

i checked the code a couple of times. i even copied your scripts and just changed the month names

aveeeeeee7en
Specialist III
Specialist III

Can you attach your application here. I'll from my end.

ashfaq_haseeb
Champion III
Champion III

Hi,

use the below expression for sorting

=match("Your Month Field" ,'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')


If possible try to share sample data.


Regards

ASHFAQ

arixooo123
Creator III
Creator III
Author

Unfortunately, I don't know how to attach a file, but my original table is like this:

YearSeasonMonthSubIDCity
2014springjan (actually in Persian calendar 'فروردین')113333city 1
2013winterfeb('اردیبهشت')112222city 2
2012summer...114444city 3

though the problem applies to other fields(Year,Season) but since the number of them are limited, it is not important that they are not sorted, but month list box has 12 values and it is much more convenient  to have them sorted.

when i use the last scripts, it does not sort the months and also by selecting months in list box, they move with no order. it is weird. 

ashfaq_haseeb
Champion III
Champion III

Hi,

Still I would suggest you to upload  sample document with some data.

SeePreparing examples for Upload - Reduction and Data Scrambling for how to do that.

Regards

ASHFAQ

arixooo123
Creator III
Creator III
Author

dear ashfagh, thanks for the tip

here is the sample data. the field of month is : [Shamsi Month],