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

MrXsquared
  • 34,292
  • 21
  • 67
  • 117
ASanders
  • 157
  • 1
  • 12

1 Answers1

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')

MrXsquared
  • 34,292
  • 21
  • 67
  • 117
  • 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 '21 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 '21 at 13:28
  • I can't make this one work. But thank you for your help! – ASanders Nov 23 '21 at 14:17