3

I have a label formula in QGIS that shows the name of a polygon and the remaining km of survey left to do:

"Name"  ||  '\n'  || round("Length_km_sum", 2)

But when I have an area that is complete (i.e. length_km value for the polygon shows as NULL) I would like for the label to show 0 or 'Complete'.

Right now if the value is NULL the label doesn't even show on the map.

2
  • 5
    have you tried using the coalesce function? try: "Name" || '\ n' || coalesce (round ("Length_km_sum", 2), 0)
    – pigreco
    Commented Jun 6, 2021 at 8:28
  • 2
    @pigreco This seems to be a/the answer
    – Babel
    Commented Jun 6, 2021 at 9:27

1 Answer 1

4

In these cases a good solution is to use the coalesce() function like this:

"Name" || '\ n' || coalesce(round("Length_km_sum", 2), 0)
1
  • One error to fix and this solution worked perfectly, many thanks- "Name" || '\n' || coalesce(round("Length_km_sum", 2), 0) Commented Jun 7, 2021 at 7:22

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.