I would like to sort child records in form view of attributes in QGIS to be sorted by an integer field but in the same time show a different expression in from list. enter image description here When setup it's working fine - expression displayed by the expression"first_field"||' - '||"second_field", sorted just by the first integer field "first_field"

But when I move to the next parent record it's sorted by the compund expression as a string. The same happens with a simple form view of table without childs when you reopen the table form. The custom sorting expression is still there but not applying. I'm not sure if it's a bug or I'm missing something. enter image description here

Version Of QGIS 3.22.6

1 Answer 1


I think it's a bug, the same thing happens to me when closing the form and reopening.

Your best workaround for now may be to use zero-padding for the first field in the display expression (e.g. lpad("first_field",4,'0') || ' - ' || "second_field") resulting in e.g. 0059 - 114, 0867 - 1254, and not using a custom sort expression.

That way it will sort in the correct order. (You might choose to use zero-padding for the second field too just so it looks better).

  • I have raised an issue on QGIS, let's see if it can be fixed easily.
    – Albine Pro
    Jul 11, 2022 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.