Skip to main content

Hi, 

 

Need help on How to sort the result of the column with Expression?

Below is a drop down list of the company, with Code - Company Name, currently the code is the one sorted in ascending order

 

the code - company is column with expression because we put a hypen (-), I tried to add an order by in the expression but i got unknown error.

 

I tried to sort the column company but the drop down didn't sort out, it only sort the list of the company.

Could anyone help how to sort the company name instead of a code name in  the dropdown list

 

Thank you in advance

 

@Jheng This is possible in a way.
 

On the lookup table or view you set the “Sort” on “Company name” as per example. On the table/view you have the column with a lookup, make sure the “lookup control’ is set to “Combo (sorted)”, so not “Combo (alphabetical)”

 

Subject → Columns → Look-up


This can be set under “Subjects” - > “Columns” → “Look-up”

This is for the specific case. If you always want to this way whenever you are going to enable another lookup to that table/view, make it the same on the “Settings” of the lookup table/view.
 

Subject → Settings

 


Hi ​@Mark_Plaggenborg 

 

Thank you for your reply, however I have an issue under “Subjects” - > “Columns” → “Look-up” the column "company_name” don't have reference

 

 

but under the Subject  → settings , I can change to combo(sorted)

 

If i just change under the settings, the drop-down company still not sorted.

note that on my dropdown, there are 2 combined column, 1-is the code, 2-is the company,

where in we add another column with expression

select concat(t1.codename, ' - ' , t1.company_name_1)

 

 Thank you

 


To add, Mark does mention the correct setting: 

  • Combo (sorted) - a value from a combo box can be selected. The list is sorted according to the default sorting of the look-up subject.

Settings for Subjects | Thinkwise Documentation

The Company field in your end product has a look-up reference, presumably to the table Company. That look-up reference has a Look-up control which I think is Combo (Alphabetical) at the moment.

To ensure the combobox is sorted on company_name_1, the subject targeted in the reference should have the sorting based on this column, and the look-up control should be set to Combo (sorted).


@Jheng I’ll try to make it a bit more clear with an example. I am using slightly adapted column names to prevent misinterpreting the purpose of them in your exact situation.

Table:
- company

Columns:
- company_id (pk)
- company_name
- company_code
- exp_company_lookup_name_1 (expression)

The expression could be: CONCAT_WS('-', t1.company_code, t1.company_name)

On this table you set the lookup setting under “Settings” of the “Subject”.

Display column: exp_company_lookup_name_1
Def. control: Combo (sorted)

On this same table you also set the “Sort”:
- company_name

Now you have another entity like a View/Table where you have a value where you wish to select a company. On this entity you have set a Reference (lookup) that is referring to table company (company_id = company_id).

So when you go to this entity (not table “Company”) and go that specific column where you need to select the company under “Subjects” → “Columns” → “Lookup”, you should see that it has the setting you need and maybe need to change at this point.

Meaning change the Def. control: Combo (sorted)

I hope this helps you.


Hi ​@Mark_Plaggenborg 

 

Thank you so much! it works now, your guide really help me find where to update the sorting, i forgot that there's another reference table

Basically, I update only 2 things.

 

The other reference table (not table “Company”)  here is where I have to update the lookup to Def. control: Combo (sorted) under “Subjects” → “Columns” → “Lookup”

 

In company table I only have to change the Sort order to ascending to the company_name column.

 

Thank you.

 


Reply