<?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: Label expression in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545840#M5905</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def FindLabel ( [TRAKT] &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if " " not in [TRAKT]:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Building = [TRAKT]&lt;/P&gt;&lt;P&gt;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Building = [TRAKT].split(" ")[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp; return "&amp;lt;CLR red = '255'&amp;gt;" + Building + "&amp;lt;/CLR&amp;gt;" + " " + [BLOCKENHET]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Mar 2016 13:54:13 GMT</pubDate>
    <dc:creator>JimmyKroon</dc:creator>
    <dc:date>2016-03-18T13:54:13Z</dc:date>
    <item>
      <title>Label expression</title>
      <link>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545835#M5900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need help with Label Expression.&lt;/P&gt;&lt;P&gt;I am using a VBScript to get the name of a building (it can have double name like NÄS GANS) from TRAKT and the the number of the building (1:12 or something like that). I do not want to print out the first part of the name, in the case above GANS. The code works fine, except when a building has not got a double name (NÄS), then nothing is printing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function FindLabel ( [TRAKT], [BLOCKENHET] )&lt;/P&gt;&lt;P&gt;&amp;nbsp; FindLabel = "&amp;lt;CLR red = '255'&amp;gt;" &amp;amp;Split(&amp;nbsp; [TRAKT], " ", 2)(1) &amp;amp; "&amp;lt;/CLR&amp;gt;" +" "+ [BLOCKENHET]&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;I have attached an image to make myself understandably:) &lt;/P&gt;&lt;P&gt;Please could anyone help? &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Tomas Looström&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 11:01:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545835#M5900</guid>
      <dc:creator>TomasLooström</dc:creator>
      <dc:date>2016-03-18T11:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Label expression</title>
      <link>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545836#M5901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see the logic... I think... but I use python which uses zero-based indexing and allows negative slicing (ie slicing from the end of a sequence)&lt;/P&gt;&lt;P&gt;So if this is correct, you do it in the language of choice&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "Nas s:101&amp;gt;2"
&amp;gt;&amp;gt;&amp;gt; b = "Nas Gans 1:12&amp;gt;5"
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; print(a.split(" ")[0] + "\n" + a.split(" ")[-1])
Nas
s:101&amp;gt;2
&amp;gt;&amp;gt;&amp;gt; print(b.split(" ")[0] + "\n" + b.split(" ")[-1])
Nas
1:12&amp;gt;5
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:37:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545836#M5901</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T23:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Label expression</title>
      <link>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545837#M5902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could add an if/else statement to check if the building has two names. (Fair warning, I'm also more familiar with Python so my VB syntax probably isn't correct.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dim buildingName as string&lt;/P&gt;&lt;P&gt;if Split(&amp;nbsp; [TRAKT], " ", 2) = "" then buildingName = [TRAKT]&amp;nbsp;&amp;nbsp;&amp;nbsp; ## If 2nd word in TRAKT is empty, then use the entire cell value.&lt;/P&gt;&lt;P&gt;else buildingName = Split(&amp;nbsp; [TRAKT], " ", 2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then build your label expression using buildingName.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 12:37:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545837#M5902</guid>
      <dc:creator>JimmyKroon</dc:creator>
      <dc:date>2016-03-18T12:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Label expression</title>
      <link>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545838#M5903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am no programmer:/ So if any of You know how to write it in Python I am more than happy:)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 12:53:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545838#M5903</guid>
      <dc:creator>TomasLooström</dc:creator>
      <dc:date>2016-03-18T12:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Label expression</title>
      <link>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545839#M5904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did...sort of... just replace my variable names with your field names... I don't do labelling so I don't know if it uses python field calculator syntax with ! stuff ! enclosing exclamation marks or [ ] like old VB stuff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 13:34:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545839#M5904</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-18T13:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Label expression</title>
      <link>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545840#M5905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def FindLabel ( [TRAKT] &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if " " not in [TRAKT]:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Building = [TRAKT]&lt;/P&gt;&lt;P&gt;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Building = [TRAKT].split(" ")[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp; return "&amp;lt;CLR red = '255'&amp;gt;" + Building + "&amp;lt;/CLR&amp;gt;" + " " + [BLOCKENHET]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 13:54:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545840#M5905</guid>
      <dc:creator>JimmyKroon</dc:creator>
      <dc:date>2016-03-18T13:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Label expression</title>
      <link>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545841#M5906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;... one way to do it in VBscript&amp;nbsp; (Original question implied vbScript)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dim NumberOfWords, myLabel
dim YourField


YourField = [YourStringField]


ArrayTemp = split(YourField," ")
NumberOfWords = UBound(ArrayTemp) + 1
Select Case NumberOfWords
&amp;nbsp; case 1&amp;nbsp; 'One word
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myLabel = YourField
&amp;nbsp; case 2&amp;nbsp;&amp;nbsp; 'Two Words
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myLabel = YourField
&amp;nbsp; case 3&amp;nbsp;&amp;nbsp; 'Three words as in your example
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myLabel = ArrayTemp(1) &amp;amp; "" &amp;amp; ArrayTemp(2)&amp;nbsp;&amp;nbsp; 'Second and Last Word
&amp;nbsp; case else&amp;nbsp; 'more than 3 words
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myLabel = YourField 'or further processing
end select&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:37:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/label-expression/m-p/545841#M5906</guid>
      <dc:creator>TedKowal</dc:creator>
      <dc:date>2021-12-11T23:37:16Z</dc:date>
    </item>
  </channel>
</rss>

