1

I found this question and the anwser did help me somewhat. But my ''code'' for the label seems to have some sort of error. It won't show any label when I apply it. I've tried the following examples to try and get it to work:

Try 1 Try 2 Try 3

Does anyone have advice for me to try and make a working label? I'm not very wellversed in making codes/rules like this.

Edit: enter image description here

1
  • So I have to replace all '||' with '()'?
    – ASanders
    Nov 23, 2021 at 12:21

1 Answer 1

2

Use concat() function. It ignores NULL values and returns an empty string '' instead of NULL and therefore gives you a result if one or more fields are NULL. This is not the case for || concatenator. || returns NULL as result if at least one field/value is NULL.

Use concat the following:

concat("myfield_a",'my string a',"myfield_b",' --> ',NULL,"myfield_c",'blablabla')

To skip concatenations of empty fields, e.g. concat("field_a",' is empty') you can use a simple if() statement: concat("field_a", if("field_a" is null,'',' is empty')) or coalesce() together with ||: concat(coalesce("field_a"||' is empty'),'',"field_b", ' is never empty')

3
  • Yes this worked, thank you! Do you know if its possible to add enters so I can order the fields vertically? And is there maybe a way for the fieldname to not show is the fieldvalue is null?
    – ASanders
    Nov 23, 2021 at 13:20
  • Ah I already managed to do so x) I did mean linebreak. I'll add a picture of what I have now. Maybe adding coalesce() will be what I need. In the picture I showed I want to hide the lines ''Glas'', ''Lamp'' and ''Benen naald'', because there is no values in those fields for certain points
    – ASanders
    Nov 23, 2021 at 13:28
  • I can't make this one work. But thank you for your help!
    – ASanders
    Nov 23, 2021 at 14:17

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.