Select to view content in your preferred language

labeling in Arcade

622
4
Jump to solution
09-04-2023 02:11 AM
IngridAnneessens
New Contributor II

I want to label my feature as follows:

when ADRESSTATUS = Gehistoreeerd -> No label
when BUSNUMMER = Null --> Huinummer
When BUSNUMMER is not NULL --> Huisnumer underlined

I keep getting an 'invalid expression' 
Can anyone see what's wrong here? Is there a beter way tot do this?

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

tl;dr:

 

return When(
    Adresstatus == "Gehistoreerd", null,
    IsEmpty(Busnummer), Huisnummer,
    !IsEmpty(Busnummer), `<UND>${Huisnummer}</UND>`,
    "Default value"
    )

 

 

 

A few pointers:

  • return + something is not valid syntax. return something is. More info on return.
  • = is for assignment (this variable now has this value), == is for comparison (does this variable have this value?) More info on operators.
  • You can append multiple string values (what you tried with the <u>), but you have to actually make them strings using quotation marks, and you have to either add them ("<UND>" + Huisnummer + "</UND>") or use template literals, which I did above.
  • Label formatting tags are not the same as HTML tags.
  • For chained if-then blocks, you can use the When function.

Have a great day!
Johannes

View solution in original post

4 Replies
ChristopherCounsell
MVP Regular Contributor

You are missing a ')' at the end of line 5.

0 Kudos
IngridAnneessens
New Contributor II

I don't see where I have to put it:
if (!IsEmpty(Busnummer)) {return + Huisnummer};

0 Kudos
JohannesLindner
MVP Frequent Contributor

tl;dr:

 

return When(
    Adresstatus == "Gehistoreerd", null,
    IsEmpty(Busnummer), Huisnummer,
    !IsEmpty(Busnummer), `<UND>${Huisnummer}</UND>`,
    "Default value"
    )

 

 

 

A few pointers:

  • return + something is not valid syntax. return something is. More info on return.
  • = is for assignment (this variable now has this value), == is for comparison (does this variable have this value?) More info on operators.
  • You can append multiple string values (what you tried with the <u>), but you have to actually make them strings using quotation marks, and you have to either add them ("<UND>" + Huisnummer + "</UND>") or use template literals, which I did above.
  • Label formatting tags are not the same as HTML tags.
  • For chained if-then blocks, you can use the When function.

Have a great day!
Johannes
IngridAnneessens
New Contributor II

Thank you, Johannes!

0 Kudos