2

I'm using the value relation widget to populate fields from a .csv-table with values corresponding to a chosen value.

I don't know why, but the label caption displayed on the map is showing the key column and not the value which is related. Any ideas what I'm doing wrong here?

I'm using the current_value() filter.

1 Answer 1

7

You need to label your layer with an expression (click the Epsilon symbol to the right of the 'Label with' drop down menu in layer properties, under the labels tab).

enter image description here

In the expression builder dialog, enter the following expression:

attribute(get_feature('VALUE_LAYER_NAME', 'KEY_FIELD', KEY), 'VALUE_FIELD')

Where:

VALUE_LAYER_NAME is the name of the layer having the value column (your csv table)

KEY_FIELD is the name of the key column in your csv layer

KEY is the name of the field in your spatial layer which your are populating from the csv

VALUE_FIELD is the name of the column in the csv table which contains the values

2
  • that's doing the trick! I still don't understand why it just worked in an older project. values were stored into the new created value and displayed just by using this column. Commented Sep 29, 2019 at 9:30
  • 1
    What version of QGIS are you using now, and what version were you using for the old project? It was probably a change in how the value relation widget works - review the changelogs if you really want to know when the change happened. (If you do, please add that information to your question - it would be useful for others with the same issue.)
    – csk
    Commented Sep 30, 2019 at 19:01

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.