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
Taras
35.7k5 gold badges77 silver badges151 bronze badges
asked Jan 13, 2023 at 10:55
4
  • Why use Value Relation ? If you use List, you'll have a complete list of unique values in your test column. Commented Mar 2, 2023 at 14:10
  • List is greyed out Commented 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. Commented 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! Commented 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

answered Mar 3, 2023 at 16:03
3
  • I cant add new Values with this in the atribute form or can i? Commented Mar 6, 2023 at 7:47
  • For me, you can't. Commented Mar 17, 2023 at 15:24
  • Then, this isnt an option for me! Commented 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.

Taras
35.7k5 gold badges77 silver badges151 bronze badges
answered Mar 3, 2023 at 17:02
5
"fid" = array_first(array_agg("fid", group_by:="Direction"))

enter image description here

Taras
35.7k5 gold badges77 silver badges151 bronze badges
answered Mar 4, 2023 at 8:58
1
  • This changes my values from e.g. "abc" to "(abc)" and completer doesnt work... Commented Mar 6, 2023 at 15:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.