8

In QGIS 3.24.3 I have a GeoPackage table containing a text field "box_id". Within its Layer Properties > Attributes Form page I have assigned it a Unique Values widget type as shown here:

enter image description here

However, when I subsequently edit the table the widget displays the unique values in a random order, as shown here:

enter image description here

How do I display them in ascending order?

A review of the QGIS docs, as well as an internet search, turned up nothing.

3
  • 2
    I don't know (and have not investigated) why the values are not sorted when using Unique Values widget type. But a workaround is to use the Value Map widget type and select the option to Load Data From layer and use value and description from your box_id field. You will get a sorted dropdown containing all unique values already present in that field.
    – Ben W
    Commented May 30, 2022 at 7:10
  • 2
    @BenW that's perfect - thanks! If you want to change your comment to an answer I'd be happy to give you credit, along with the bonus points!
    – Stu Smith
    Commented May 30, 2022 at 15:53
  • No worries, done :-)
    – Ben W
    Commented May 30, 2022 at 23:41

1 Answer 1

2
+200

Instead of using the Unique Values widget type, a workaround is to use the Value Map widget type and select the option to Load Data From Layer. Then, using your kestrel_box_inspections layer, select Value and Description from your box_id field.

enter image description here

As a result, you will get a sorted dropdown in your attributes form containing all unique values taken from the selected layer and field.

enter image description here

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.