Hello,
I have arcgis pro 2.7.2 and sde. I need to concatenate two fields in same feature class. I found a few samples from geonet. i tested it on my end by using attribute rule but it is not working. can you please assist? thank you.
Solved! Go to Solution.
here's an example of one that I use:
// Specify the fields to concatenate
var values = [$feature.PreDir, $feature.StreetName, $feature.SufType, $feature.SufDir]
var combined_value = [];
// Loop through the field values and test if they are null or empty strings
// If they are not null or empty add them to an array
for (var i in values) {
var value = values[i];
if (IsEmpty(value)) continue;
combined_value[Count(combined_value)] = value
}
// Return the field values concatenated with a space between
return Concatenate(combined_value, " ");
Concatenate() function works for me. Double-click the function and fieldnames from above list to insert into the expression. Don't type it up.
Expression:
Concatenate($feature.Field1, " ", $feature.Field2)
or
$feature.Field1+" "+$feature.Field2
@JayantaPoddar Thank you for the information. what about if it is null? does it still show space like " " if it is null next to it?
here's an example of one that I use:
// Specify the fields to concatenate
var values = [$feature.PreDir, $feature.StreetName, $feature.SufType, $feature.SufDir]
var combined_value = [];
// Loop through the field values and test if they are null or empty strings
// If they are not null or empty add them to an array
for (var i in values) {
var value = values[i];
if (IsEmpty(value)) continue;
combined_value[Count(combined_value)] = value
}
// Return the field values concatenated with a space between
return Concatenate(combined_value, " ");
@JoeBorgione Thank you for the information. If I am understanding correctly, it looks like it will accept with null or no null during concatenate?
You make a list of all the fields you want to concatenate; then step through that list, and if a given field is empty or null, you do not concatenate that into the returned output.