QGIS 3 Labeling – Displaying Description Instead of Value in Value Map Attributes

labelingqgis-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

Best Answer

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

Related Question