Arcade expression to place attributes on separate lines from one field

276
5
Jump to solution
01-21-2021 07:02 AM
CMcDonald
Occasional Contributor

Hi,

I have a dataset whereby several attributes have been entered into one single field and would like to put each on a new line so that the attribute window is much clearer.  Each entry is separated by a semicolon ;  Currently this looks like:

CMcDonald_0-1611240914087.png

Is it possible to separate into:

Amenity Accommodation - 14

Flat - 65

Four in a Block - 60

House - 66

Sheltered Accommodation - 38

There are also other Housing types available in different polygons.  I wondered if some sort of IF = statement would be required to create the expression?

Thanks in advance

p.s. if Arcade is a suitable solution i am a novice

 

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi @CMcDonald ,

 

Your code would look like this:

var test1 = $feature.PROPBREAKDOWN;
var test2 = Replace(test1, "; ", ";");
var list = Split(test2, ";");
var result = Concatenate(list, TextFormatting.NewLine);
return result;

 

The value in the text that follows Amenty Accommodation does not affect the expressión It is just part of the text. The initial text is separated by the semicolon. It does not matter much what comes before or after the semicolon. Let me know if it works or if you need any further explanation. 

View solution in original post

5 Replies
XanderBakker
Esri Esteemed Contributor

Hi @CMcDonald ,

This can be done with Arcade. Have a look at the example below:

// var test1 = $feature["Name of your Field goes here"];
var test1 = "Amenity Accommodation - 14; Flat - 65; Four in a Block - 60; House - 66; Sheltered Accommodation - 38";
var test2 = Replace(test1, "; ", ";");
var list = Split(test2, ";");
var result = Concatenate(list, TextFormatting.NewLine);
return result;

The first line is commented ("//"), but explains how you could connect to the field that contains the list. The second line is just to create a variable with the list that you used in your example.

On the third line I first replace all the "; " (including the space) for just the ";" to avoid having redundant spaces and the start of each element.

On line 4 I use Split to split the text into a list of 5 elements

On line 5 the Concatenate function helps to create a text and we combine the elements with a new line. Ths will result in a multililine text:

XanderBakker_0-1611248219931.png

 

CMcDonald
Occasional Contributor

Thanks @XanderBakker 

Because I'm a total novice with Arcade I'm struggling understanding the code.  The field name would be PROPBREAKDOWN so my first line of code looks like below, I'm assuming I shouldn't have this commented out i.e. //

var test1 = $feature.PROPBREAKDOWN
var test1 =

I'm then not sure about line 2, should i just copy & paste green text.  How does this work if other polygons in the dataset have different values against them i.e. if Amenity Accommodation had a value of 20 or 50 etc.

Thanks

Reply
0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @CMcDonald ,

 

Your code would look like this:

var test1 = $feature.PROPBREAKDOWN;
var test2 = Replace(test1, "; ", ";");
var list = Split(test2, ";");
var result = Concatenate(list, TextFormatting.NewLine);
return result;

 

The value in the text that follows Amenty Accommodation does not affect the expressión It is just part of the text. The initial text is separated by the semicolon. It does not matter much what comes before or after the semicolon. Let me know if it works or if you need any further explanation. 

View solution in original post

CMcDonald
Occasional Contributor

Excellent!, thanks @XanderBakker 👍

Reply
0 Kudos
XanderBakker
Esri Esteemed Contributor

You're Welcome @CMcDonald . I am glad it works.

Reply
0 Kudos