Select to view content in your preferred language

Problem with Arcade Expression for Pop-Ups

2567
12
07-02-2020 06:44 AM
BrianE
by
Frequent Contributor

New to Arcade and have been exploring it for the last week or so. I have run into an issue with a pop-up.

I am mapping the locations of numerous companies. Some have one location, others have up to six locations. I am writing an expression that will list the locations and their corresponding square footage. So, a company with just one location will have just one line with their address and SF, companies with two locations will have 2 lines (one line for each location), etc.

This is what I have so far:

$feature["ADDRESS_1"] + "  (" + Text($feature["SQUARE_FEET_1"], '#,###') + " RSF)" + TextFormatting.NewLine +

$feature["ADDRESS_2"] + "  (" + Text($feature["SQUARE_FEET_2"], '#,###') + " RSF)" + TextFormatting.NewLine +

$feature["ADDRESS_3"] + "  (" + Text($feature["SQUARE_FEET_3"], '#,###') + " RSF)" + TextFormatting.NewLine +

$feature["ADDRESS_4"] + "  (" + Text($feature["SQUARE_FEET_4"], '#,###') + " RSF)" + TextFormatting.NewLine +

$feature["ADDRESS_5"] + "  (" + Text($feature["SQUARE_FEET_5"], '#,###') + " RSF)" + TextFormatting.NewLine +

$feature["ADDRESS_6"] + "  (" + Text($feature["SQUARE_FEET_6"], '#,###') + " RSF)" + TextFormatting.NewLine

 

I cannot figure out how to have the pop up display ONLY the lines with their locations. I tried messing around with the DefaultValue function but that didn't give me the result I needed.

I have attached a jpeg with current and desired pop-up appearance.

Thanks

Tags (1)
0 Kudos
12 Replies
KenBuja
MVP Esteemed Contributor

I just tested your code with a dummy dataset I created and it works as expected.

Expression:

var output = $feature["ADDRESS_1"] + TextFormatting.NewLine
if (!IsEmpty($feature["ADDRESS_2"])){
  output += $feature["ADDRESS_2"] + TextFormatting.NewLine
}
if (!IsEmpty($feature["ADDRESS_3"])){
  output += $feature["ADDRESS_3"]  + TextFormatting.NewLine
}
return output‍‍‍‍‍‍‍‍

Table

Popup:

0 Kudos
BrianE
by
Frequent Contributor

Yes this worked! Thank you.

However, this RSF value is missing from the expression and the pop up

0 Kudos
BrianE
by
Frequent Contributor

Figured it out:

var output = $feature["ADDRESS_1"] + " (" + Text($feature["SQUARE_FEET_1"], '#,###') + " RSF)" + TextFormatting.NewLine
if (!IsEmpty($feature["ADDRESS_2"])){
output += $feature["ADDRESS_2"] + " (" + Text($feature["SQUARE_FEET_2"], '#,###') + " RSF)" + TextFormatting.NewLine
}
if (!IsEmpty($feature["ADDRESS_3"])){
output += $feature["ADDRESS_3"] +- " (" + Text($feature["SQUARE_FEET_3"], '#,###') + " RSF)" + TextFormatting.NewLine
}
if (!IsEmpty($feature["ADDRESS_4"])){
output += $feature["ADDRESS_4"] +- " (" + Text($feature["SQUARE_FEET_4"], '#,###') + " RSF)" + TextFormatting.NewLine
}
if (!IsEmpty($feature["ADDRESS_5"])){
output += $feature["ADDRESS_5"] +- " (" + Text($feature["SQUARE_FEET_5"], '#,###') + " RSF)" + TextFormatting.NewLine
}
if (!IsEmpty($feature["ADDRESS_6"])){
output += $feature["ADDRESS_6"] +- " (" + Text($feature["SQUARE_FEET_6"], '#,###') + " RSF)" + TextFormatting.NewLine
}
return output 

0 Kudos