Arcade Label Expression Help

208
1
03-23-2023 10:13 AM
STanguay
New Contributor

I am trying to label the name of occupants of cemetery lots in ArcGIS Pro. I have some cases where one lot has more 2+ occupants. I would like both names to be displayed on the map. 

My fields consist of First Name & Last Name. When a maiden name was provided, it was included in the First Name field in brackets. I have since removed the maiden name from the label to allow for more space. 

I have copied my current expression below. It is valid but I feel I am missing part of the syntax to allow my 2 statements to work together.

In the case where there are 2 occupants, i am trying to get my final label to appear like 'Jane Doe & John Smith'

var LN1= $feature.LastName
var FN1 = $feature.FirstName
var LN2 = $feature.LastName_2
var FN2 = $feature.FirstName_2
var a= Split($feature.FirstName,'(',-1, true)

if(IsEmpty(LN1) == False){
return a[0] + ' ' + LN1 }
else if (IsEmpty(LN2) == False){
return '&' + FN2 + ' ' + LN2 }

 

I am new to working with Arcade any help or recommendations are greatly appreciated! 

0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor
var LN1= $feature.LastName
var FN1 = Split($feature.FirstName,'(',-1, true)
var LN2 = $feature.LastName_2
var FN2 = $feature.FirstName_2

if(IsEmpty(FN2)) {
    return `${FN1} ${LN1}`
}
return `${FN1} ${LN1} & ${FN2} ${LN2}`

Have a great day!
Johannes