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
36.2k22 gold badges76 silver badges127 bronze badges
asked Nov 23, 2021 at 12:01
1
  • So I have to replace all '||' with '()'? Commented 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')

answered Nov 23, 2021 at 12:33
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? Commented 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 Commented Nov 23, 2021 at 13:28
  • I can't make this one work. But thank you for your help! Commented Nov 23, 2021 at 14:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.