Attribute Rule -Concatenate joins

1447
5
Jump to solution
04-06-2021 11:20 AM
AlexP_
by
Occasional Contributor III

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.

AlexP__0-1617732314360.png

AlexP__1-1617733048087.png

 

 

0 Kudos
1 Solution

Accepted Solutions
JoeBorgione
MVP Emeritus

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, " ");
That should just about do it....

View solution in original post

5 Replies
JayantaPoddar
MVP Esteemed Contributor

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


Think Location
AlexP_
by
Occasional Contributor III

@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?

0 Kudos
JoeBorgione
MVP Emeritus

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, " ");
That should just about do it....
AlexP_
by
Occasional Contributor III

@JoeBorgione Thank you for the information.  If I am understanding correctly, it looks like it will accept with null or no null during concatenate?

0 Kudos
JoeBorgione
MVP Emeritus

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.

 

That should just about do it....