3

Is it possible to label features with the Description of a Value Map type field, instead of its Value ?

I have a shape file layer with one of the fields defined as "Value Map" (Widget Type with predefined items) that I use to label the point on the map. When I enter "name_field" in Layer Properties > Labels only the value is shown on the map.

ie field "cars" with predefined rows "Volkswagen" "VW", I'd like to use the "VW" description as label instead of "Volkswagen" value... (same as in the Attribute table) where I can select the Description, the Value is "hidden" for the user.

QGis 3.22 > Layer Properties > Labels > Value

1
  • I added an example of predefined "Value Map" row.
    – S.E.
    Commented Dec 24, 2021 at 22:21

1 Answer 1

5

Use this expression for the Value field of the label dialog, where cars is the name of the attribute field:

 represent_value( "cars")

See documentation:

Returns the configured representation value for a field value. It depends on the configured widget type. Often, this is useful for ‘Value Map’ widgets.

enter image description here

enter image description here

2
  • 1
    Great ! Couldn't find it in the doc...
    – S.E.
    Commented Dec 24, 2021 at 22:34
  • 1
    Added link to docu
    – Babel
    Commented Dec 24, 2021 at 22:37

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.