I am having some issues trying to show multiple fields for a single label in QGIS. In QGIS2.6, attempting to display labels for a feature consisting of multiple fields results in an empty label if one of the fields is null. So for example, in the label expression dialog:
concat("Temp Site",'\n',"Notes",'\n',"Function")
will function normally unless one of the fields is null, then it results in no label being shown. Using the '||' operator instead in the expression dialog also results in the same behaviour:
"Temp Site" || '\n' || "Notes" || '\n' || "Function"
Is there a way to display the labels even if one of the fields is null?
Answer
Use the "Coalesce" function. Coalesce takes the first non-null value from its arguments. So this expression should work:
coalesce("Temp Site",'') || '\n' || coalesce("Notes",'') || '\n' || coalesce("Function",'')
No comments:
Post a Comment