I have fields with names in the format last, first, middle initial. I would like to display them as first, ME, last. Is this possible in Arcade using the Split function?
How is your data formatted? If it's in a field as "Smith, John A" then you can use
<SPAN class="keyword token">var</SPAN> arrName <SPAN class="operator token">=</SPAN> <SPAN class="token function">split</SPAN><SPAN class="punctuation token">(</SPAN>$feature<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">","</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN> arrName<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" "</SPAN> <SPAN class="operator token">+</SPAN> arrName<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
This returns "John A Smith"
I have created a Cell_ID field to store grid index values in a road feature class. For example, if Main St. falls within grid cells B1, B2, C2 & C3, my Cell_ID field is populated with "C3,B2,C2,B1". Is there any way for me to reorder the values alphabetically and then numerically as B1, B2, C2 & C3?
Solved my problem below:
var arrName = split($feature.Cell_ID, ",") return concatenate(sort(arrName))
Glad to help. Don't forget to click the "Mark Correct" button.
There's no comma just spaces, but this works. Thanks!
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.