Select to view content in your preferred language

Writing Custom Label Expressions using Arcade for ArcGIS Online?

4335
12
Jump to solution
04-24-2019 01:26 PM
NevinValles
Occasional Contributor

I'm not familiar with Arcade, but I'm trying to do a simple expression. I need to write an if-else label expression that will label addresses by their address number, unless there is a address unit number; then I would want the label to show the unit number. I've researched this documentation https://developers.arcgis.com/arcade/function-reference/logical_functions/ . I need a statement something like: If address is not Null than populate, or else populate unit number. I'm just not familiar with the Arcade structure. 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DianaLavery1
Esri Contributor

FYI, You might have to use feature notation..., meaning it might be

iif(isEmpty($feature.addrunit),$feature.addrnmbr,$feature.addrunit)

View solution in original post

12 Replies
XanderBakker
Esri Esteemed Contributor

Can you share how your data looks like and provide an example of what you would like to obtain for the different situations?

0 Kudos
NevinValles
Occasional Contributor

Sorry, this is my first time using Geonet and I added a new comment rather than replying. I'm not to sure if you will receive a notification from my comment so i'm replying here.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Nevin Valles , adding a reply to the same thread is the way to go. I'm sorry that I did not answer before, but the answer provided by Diana Lavery should be the way to go (if the field is really empty). Can you please try that suggestion? If it works, please mark her post as the right answer.

0 Kudos
NevinValles
Occasional Contributor

I need the address numbers to display/label by default, unless there is an address for the unit. There can be many units associated to the one address and we need to display these. For example, a parcel with 10 units should display the 10 unit numbers as separate points, but there is still an individual point with just the address number that should be displayed as well.

Address Data TableAddress Data Table

0 Kudos
DianaLavery1
Esri Contributor

Try combining the "isEmpty()" and the "iif()" logic functions, which works similar to the if-function in Excel:

IIf( condition, trueValue, falseValue )

in your case, it sounds like it would be

iif(isEmpty(addrunit),addrnmbr,addrunit)

Here's the Arcade Function Reference list for your reference:

https://developers.arcgis.com/arcade/function-reference/

0 Kudos
DianaLavery1
Esri Contributor

FYI, You might have to use feature notation..., meaning it might be

iif(isEmpty($feature.addrunit),$feature.addrnmbr,$feature.addrunit)

NevinValles
Occasional Contributor

Hi Diana,

I'm still not getting the labels to display correctly. It is displaying only some of the ADDRNMBR's and some of the ADDRUNIT's. 

0 Kudos
XanderBakker
Esri Esteemed Contributor

Perhaps the field is not really Empty (Null) and contains a space or something similar. This could explain the behavior.

NevinValles
Occasional Contributor

I've made sure that the field is empty. Once I type in any number to ADDRUNIT that number will be labeled, but once I delete that unit number then the ADDRRNMBR is displayed. Otherwise, there is no label displayed. 

0 Kudos