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
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).
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
-
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.Eric Walter– Eric Walter2019年09月29日 09:30:26 +00:00Commented Sep 29, 2019 at 9:30
-
1What 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– csk2019年09月30日 19:01:01 +00:00Commented Sep 30, 2019 at 19:01