6

In ArcGIS Online, I have a point layer with attributes Provider1, Provider2, Provider3.....Provider13. The values are text consisting of people's names.

I would like to configure the popup to concatenate the Providers separated by a semi-colon. However, some points only have a value for Provider1. Other points only have a value for Provider1 and Provider2. Other points only have a value for Provider1, and Provider2, and Provider3... etc.

Currently I simply have:

Concatenate($feature.PROVIDER1, ';', $feature.PROVIDER2, ';', 
$feature.PROVIDER3,';', $feature.PROVIDER4,';',$feature.PROVIDER5)

But for points that have only Provider1, the popup shows:

John J. Doe; ; ; ;

Is there a way to to have the expression "stop" trying to concatenate when it encounters an empty Provider value?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 8, 2017 at 23:13
1
  • Yes is the short answer, you want to be studying the logic functions here. May be the IIF or When functions? Commented Nov 8, 2017 at 23:22

1 Answer 1

7

You must test IsEmpty for each value. You may try this code using the Labeling Profile at the Arcade Playground

//Array to hold values and an index
var i = 0;
var features = [];
//Add value to array if not empty
function addvalue(feat) {
 if (!IsEmpty(feat)) {
 features[i++] = feat;
 }
}
//Add your values
addvalue($feature.name1);
addvalue(Null);
addvalue($feature.name2);
addvalue("");
addvalue("text");
//Return a concatenated string
return Concatenate(features, ";")

This will return:

value1;value2;text
Squanchy
5422 gold badges6 silver badges20 bronze badges
answered Nov 26, 2017 at 19:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.