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:
Does anyone have advice for me to try and make a working label? I'm not very wellversed in making codes/rules like this.
-
So I have to replace all '||' with '()'?ASanders– ASanders2021年11月23日 12:21:05 +00:00Commented Nov 23, 2021 at 12:21
1 Answer 1
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')
-
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– ASanders2021年11月23日 13:20:23 +00:00Commented 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 pointsASanders– ASanders2021年11月23日 13:28:43 +00:00Commented Nov 23, 2021 at 13:28
-
I can't make this one work. But thank you for your help!ASanders– ASanders2021年11月23日 14:17:20 +00:00Commented Nov 23, 2021 at 14:17
Explore related questions
See similar questions with these tags.