2

In the print layout of QGIS (I use 3.12.2 on Win) you can add an attribute table. I have a list of towns I want to display ordered according to their size (population). That's quite easy: in the feature properties of the table just select main properties and than attributes. There, you can select which fields from the attribute table of a certain layer you want to show - even custom-generated fields with expressions are possible. Beneath, you can choose one of the fields defined above for the sort order. Perfect! It orders my towns in the correct order.

However, I would like to display the no. of inhabitants in a formatted style with a delimiter - thus 1.000.000 instead of 1000000. Works perfectly with the expression format_number(population,0). The problem: formatted this way, the sort-order seems to interpret the numbers as strings, thus ordering like this:

15,000

150,000

20,000

200,000

1,500,000

2,000,000

It is not possible to select something else for the sorting-order than the fields that are visible in the table - thus using an additional field (hidden in the table) for the definition of the sorting order is not possible.

I tried to create a virtual layer as explained here: https://gis.stackexchange.com/a/339276/88814.

However, that is not a solution in my case (see why here: QGIS: no geometry in virtual layer). So how can I implement a correct sort ordering that respects the desired formatted numbers?

enter image description here

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.