0

So I have a complex question. Initially I needed to know how to do a word wrap on a single label in QGIS because I have a county name that is too long for the county it belongs to. I was told how to do a word wrap function.

However, my labels also have data from a second column in the attribute table that goes beneath the county name.

My question is how do I combine both functions in the expression so that the one county with its long name word wraps, but all the labels also get the data from that second column? For reference, here is the link to the first question I asked: How do I edit a single label in QGIS 3.4 (Madeira)?

1

1 Answer 1

1

Using the accepted answer from your previous question you can do this easily by editing the existing label expression:

Case
When  "FieldOne" =  'Golden Valley' Then wordwrap("FieldOne",6) || '\n' || FieldTwo
else "FieldOne" || '\n' || FieldTwo
End 

This uses the Case statement to identify whether or not the name in FieldOne is 'Golden Valley'. If it is then it wraps that label onto two lines, then uses the || (which is a string concatenator) and '\n'(which is a new line) characters to add the value of Fieldtwo onto the end of the string as a new line.

Replace FieldOne and FieldTwo with the names of your two input fields.

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.