<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How Do I REMOVE X Characters From the Right Using Arcade? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/1173006#M55063</link>
    <description>&lt;P&gt;This worked perfectly for most of my data, but I need to exclude all points where txt = 'Unavailable'. Is there an easy way to exclude certain values from the expression?&lt;/P&gt;</description>
    <pubDate>Wed, 11 May 2022 19:58:32 GMT</pubDate>
    <dc:creator>NCESOpen_Data</dc:creator>
    <dc:date>2022-05-11T19:58:32Z</dc:date>
    <item>
      <title>How Do I REMOVE X Characters From the Right Using Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/180771#M8016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I finally have a new laptop and it's about to be a new fiscal year, so I am starting off my new GIS project with a clean slate--as in I'm kicking all my kludged together maps and bloated geodatabase with dozens and dozens of orphaned items to the curb.&amp;nbsp; I have been putting off using Arcade, but since I also plan on publishing more content to our portal, I want to start using it to make life easier for those online maps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current dilemma is that I can't figure out how to manipulate a label string the way I need to.&amp;nbsp; I have a field (Office Name) that includes the City and State.&amp;nbsp; To make labelling easier, I want to remove the last three characters in that field, which is a space and then the two character state abbreviation.&amp;nbsp; With Python, I can do it thusly:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel ( [OFC_NM] ):
 L = [OFC_NM]
 L = L.title()
 L = L[:-3]
 return L&lt;/PRE&gt;&lt;P&gt;How&amp;nbsp; the heck do I&amp;nbsp;this&amp;nbsp;(properly) with Arcade?&amp;nbsp;&lt;/P&gt;&lt;P&gt;arcade formatting‌ arcade language‌ string.format‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:09:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/180771#M8016</guid>
      <dc:creator>ChrisLope</dc:creator>
      <dc:date>2021-12-12T16:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I REMOVE X Characters From the Right Using Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/180772#M8017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There&amp;nbsp;are &lt;A href="https://developers.arcgis.com/arcade/function-reference/text_functions/"&gt;Left, Mid, and Right functions.&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2020 15:45:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/180772#M8017</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-08-28T15:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I REMOVE X Characters From the Right Using Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/180773#M8018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply, Joe. Unfortunately those functions don't do what I need to be done, at least not as they are written/documented in the help file.&amp;nbsp; I actually played around with that prior to my post (should've mentioned that in my original post.)&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although using the Left function would give me the characters to the left of the string, which is what I need, there is no consistent length to the office names.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Python deals with this type of situation by allowing you to use negative numbers so using something like&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;L = "New Orleans, LA" 
L[:-3]&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;gives&amp;nbsp;you "New Orleans" when the string in the field is "New Orleans, LA".&amp;nbsp; I tried using the same logic with Arcade&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN class="" style="color: #5c2699;"&gt;Right&lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #c41a16;"&gt;&lt;SPAN class="" style="color: #c41a16;"&gt;'New Orleans, LA'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8;"&gt;, -&lt;/SPAN&gt;&lt;SPAN class="" style="color: #1c00cf;"&gt;&lt;SPAN class="" style="color: #1c00cf;"&gt;3&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;But that does not work and the labels don't actually render.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:14:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/180773#M8018</guid>
      <dc:creator>ChrisLope</dc:creator>
      <dc:date>2021-12-11T09:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I REMOVE X Characters From the Right Using Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/180774#M8019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/223688" target="_blank"&gt;Chris Lope&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a look at this expression based on the suggestion by&amp;nbsp;&lt;A href="https://community.esri.com/people/jborgion" target="_blank"&gt;jborgion&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; txt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'New Orleans, LA'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Left&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;txt&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Count&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;txt&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This will return "New Orleans" (without the comma since it took off 4 characters)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:14:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/180774#M8019</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T09:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I REMOVE X Characters From the Right Using Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/1173006#M55063</link>
      <description>&lt;P&gt;This worked perfectly for most of my data, but I need to exclude all points where txt = 'Unavailable'. Is there an easy way to exclude certain values from the expression?&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 19:58:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/1173006#M55063</guid>
      <dc:creator>NCESOpen_Data</dc:creator>
      <dc:date>2022-05-11T19:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I REMOVE X Characters From the Right Using Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/1177057#M55508</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/59020"&gt;@NCESOpen_Data&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Sorry for the delay. In your case you can use something like:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var txt = $feature["Your text field"];
if (Lower(txt) != 'unavailable') {
    txt = Left(txt, Count(txt)-4);
}
return txt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A small example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var list = ['New Orleans, LA', 'Unavailable', 'Redlands, CA', 'Manhattan, NY'];
for (var i in list) {
    var txt = list[i];
    if (Lower(txt) != 'unavailable') {
        txt = Left(txt, Count(txt)-4);
    }
    Console(txt);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will write to the console:&lt;/P&gt;&lt;LI-CODE lang="java"&gt;New Orleans
Unavailable
Redlands
Manhattan&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 24 May 2022 22:43:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/1177057#M55508</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2022-05-24T22:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I REMOVE X Characters From the Right Using Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/1405684#M81448</link>
      <description>&lt;P&gt;Thanks for the answer,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;!&amp;nbsp; I apologize for my delayed "thanks"--I didn't see it until yesterday (4/3/2024) when I came across this post while searching for a solution to the same problem I apparently had 4 years ago, hahaha.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I started fiddling around with things this time, the vague and fuzzy memories of "why is this only working on two sites out of 140ish" came back and I had the eureka moment (again) of realizing that the report that is extracted from the mainframe adds a bunch of spaces/tabs to some of the fields (e.g. "Sitename&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;" vs. "Sitename").&amp;nbsp; Back in 2020, I fixed the issue in Excel prior to pulling the sheet in as a table.&amp;nbsp; Since I'm pulling the sites from a database this time, the dirty fields are still dirty and mucking up my day.&lt;/P&gt;&lt;P&gt;The final "fix" for my problem was:&amp;nbsp; (dropping it here for when I run into this issue again in 2028, haha)&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;var txt = Trim($feature.OFC_NM);&lt;BR /&gt;return Left(txt,Count(txt)-2);&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 13:03:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-do-i-remove-x-characters-from-the-right-using/m-p/1405684#M81448</guid>
      <dc:creator>ChrisLope</dc:creator>
      <dc:date>2024-04-04T13:03:17Z</dc:date>
    </item>
  </channel>
</rss>

