5

I've got a vector layer with a QGIS Form and the column "test" in the attribute table. I have values for the columns e.g: abc, abc, abcd.

I defined a form for this Layer. The type for the column "test" is Value Relation and I checked Use Completer.

When I create a new feature for this Layer in the form I get a dropdown when I type the first letter as desired. But in the dropdown, I have three options to select: abc, abc, abcd. So abc is duplicated.

I would like to remove the duplicates from this list. I just would like to see: abc, abcd

Is there a possibility to do this?

QGIS-Version: 3.22.9

How-To-Reproduce:

  1. Open an empty Project
  2. Create an empty shape-layer with one text field
  3. In Form use Value Relation and check Use Completer
  4. Add a new feature
4
  • Why use Value Relation ? If you use List, you'll have a complete list of unique values in your test column. Mar 2, 2023 at 14:10
  • List is greyed out
    – fsg
    Mar 2, 2023 at 14:18
  • So, can you provide more information about your QGIS version, your layer source, etc. ? to help other users to reproduce your problem. Mar 2, 2023 at 14:26
  • 1
    I added some information to my question. I got the same problems for a local stored shape and a PostGIS-Layer!
    – fsg
    Mar 3, 2023 at 8:42

3 Answers 3

6
+25

You can use the Value Map form widget to have a list of unique items, even from a field with duplicate values.

From the documentation :

Value Map: A combo box with predefined items. The value is stored in the attribute, the description is shown in the combo box. You can define values manually or load them from a layer or a CSV file.

Value Map form widget

3
  • I cant add new Values with this in the atribute form or can i?
    – fsg
    Mar 6, 2023 at 7:47
  • For me, you can't. Mar 17, 2023 at 15:24
  • Then, this isnt an option for me!
    – fsg
    Mar 22, 2023 at 8:06
5

The answer by @J.Monticolo should be correct. Additionally, your data may be the source of the problem if there are blank spaces hidden in the values. For example, your values may include 'abc', ' abc', 'abc ', or ' abc '.

These often arise as data entry errors and are difficult to visually spot. They will appear separately in a value map, but because the blank spaces are difficult to notice they will appear to be duplicated.

5
"fid" = array_first(array_agg("fid", group_by:="Direction"))

enter image description here

1
  • This changes my values from e.g. "abc" to "(abc)" and completer doesnt work...
    – fsg
    Mar 6, 2023 at 15:02

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.