<?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: Conditioning labels in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730935#M56723</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried with VBScript and it worked.&amp;nbsp; After banging my head for a while against the monitor I decided to try one last thing before a break...RESTART ArcMap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then get back to Python and tried again...IT WORKED!!! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/shocked.png" /&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/plain.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't really know what happened, but Tom's suggestion make me try using the string value for the subtype instead of the number and it worked.&amp;nbsp; The final code is like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel (&amp;nbsp; [CATEGORIA],[NUM_CATASTRO], [PARCEL_SP] ):
&amp;nbsp; if [CATEGORIA] =='N/A':
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp; [NUM_CATASTRO]
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR red='255'&amp;gt;&amp;lt;FNT size = '10'&amp;gt;" +&amp;nbsp; [CATEGORIA] + "&amp;lt;/FNT&amp;gt;&amp;lt;/CLR&amp;gt; &amp;lt;CLR blue='255'&amp;gt; \n" + [PARCEL_SP] + "&amp;lt;/CLR&amp;gt;"&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Find it weird that I needed to use the description instead of the integer value for the subtype field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for the help and suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 07:12:29 GMT</pubDate>
    <dc:creator>Ulises</dc:creator>
    <dc:date>2021-12-12T07:12:29Z</dc:date>
    <item>
      <title>Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730924#M56712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to define an expression for labeling parcel polygons in ArcMap.&amp;nbsp; The feature class has 3 attributes of interest: CATEGORIA, NUM_CATASTRO, and PARCEL_SP.&amp;nbsp; If CATEGORIA (integer field with subtypes defined) is not 0 (N/A), then label the polygon with the value in PARCEL_SP, otherwise label with NUM_CATASTRO.&amp;nbsp; I'm not a programmer and I'm just starting with Python so I'm not sure what is missing.&amp;nbsp; So far I have...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel (&amp;nbsp; [CATEGORIA],[NUM_CATASTRO], [PARCEL_SP] ):
&amp;nbsp; if [CATEGORIA] ==0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return [PARCEL_SP]
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp; [NUM_CATASTRO]&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is that I can see labels for NUM_CATASTRO where they should, but none for PARCEL_SP.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I reverse the values...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel (&amp;nbsp; [CATEGORIA],[NUM_CATASTRO], [PARCEL_SP] ):
&amp;nbsp; if [CATEGORIA] ==0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp; [NUM_CATASTRO]
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return [PARCEL_SP]&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it labels the PARCEL_SP where is supposed to but not the NUM_CATASTRO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Same thing using the following statement...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel (&amp;nbsp; [CATEGORIA],[NUM_CATASTRO], [PARCEL_SP] ):
&amp;nbsp; if [CATEGORIA] !=0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp;&amp;nbsp; [PARCEL_SP]
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp; [NUM_CATASTRO]&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be appreciated...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:12:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730924#M56712</guid>
      <dc:creator>Ulises</dc:creator>
      <dc:date>2021-12-12T07:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730925#M56713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greeting Ulises!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is most likely that the values in [CATEGORIA] are not what you are expecting them to be in python.&amp;nbsp; If the field is not numeric, it will never evaluate to 0, but a text value of&amp;nbsp; "0".&amp;nbsp; It may be a Null value and again it would not evaluate to be 0.&amp;nbsp; Your logic looks sound, please check the values and make sure it is the right field type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 19:30:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730925#M56713</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2015-02-10T19:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730926#M56714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply, Tom.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field CATEGORIA is numeric, yet I'm assuming is behaving like it isn't, yet haven't been able to identify why.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 19:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730926#M56714</guid>
      <dc:creator>Ulises</dc:creator>
      <dc:date>2015-02-10T19:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730927#M56715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ulises,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are there 0 values in the field [CATEGORIA] or could it be a value of null?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 19:41:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730927#M56715</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2015-02-10T19:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730928#M56716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No null values...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 19:45:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730928#M56716</guid>
      <dc:creator>Ulises</dc:creator>
      <dc:date>2015-02-10T19:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730929#M56717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ulises,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like python automatically casts numeric field values as strings, so you would need to change your expression to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699; background-color: #f6f6f6;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000; background-color: #f6f6f6;"&gt; [CATEGORIA] == "&lt;/SPAN&gt;&lt;SPAN class="number" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: green; background-color: #f6f6f6;"&gt;0":&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="number" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: green; background-color: #f6f6f6;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="number" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: green; background-color: #f6f6f6;"&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="number" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: green; background-color: #f6f6f6;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="number" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: green; background-color: #f6f6f6;"&gt;&lt;SPAN class="keyword" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699; background-color: #f6f6f6;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000; background-color: #f6f6f6;"&gt; int([CATEGORIA]) == &lt;/SPAN&gt;&lt;SPAN class="number" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: green; background-color: #f6f6f6;"&gt;0:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 19:52:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730929#M56717</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2015-02-10T19:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730930#M56718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again.&amp;nbsp; Is not working either way.&amp;nbsp; First suggestion "0" still behaves as mentioned earlier and second option (using int) returned an error...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ValueError: invalid literal for int() with base 10:'N/A'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;N/A is the descriptive value for the subtype coded with the integer 0.&amp;nbsp; Also changed the expression to evaluate against "N/A" with no success.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 20:08:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730930#M56718</guid>
      <dc:creator>Ulises</dc:creator>
      <dc:date>2015-02-10T20:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730931#M56719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think python would be casting numeric data types to strings. That doesn't make sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 20:53:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730931#M56719</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2015-02-10T20:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730932#M56720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe post a screenshot of part of your attribute table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 20:58:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730932#M56720</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2015-02-10T20:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730933#M56721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your logic look good!&lt;/P&gt;&lt;P&gt;If you are sure that your Catagoria is numeric not null ect..... Then have tried another logical method such as :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel (&amp;nbsp; [CATEGORIA],[NUM_CATASTRO], [PARCEL_SP] ):&amp;nbsp; 
&amp;nbsp; if [CATEGORIA] &amp;gt; 0:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return [PARCEL_SP]&amp;nbsp; 
&amp;nbsp; else:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp; [NUM_CATASTRO]&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:12:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730933#M56721</guid>
      <dc:creator>TedKowal</dc:creator>
      <dc:date>2021-12-12T07:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730934#M56722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is straight from the "Building Label Expressions" in the ArcGIS Documentation.&amp;nbsp; I did a test on my data and it absolutely does cast the field values into strings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 21:01:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730934#M56722</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2015-02-10T21:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730935#M56723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried with VBScript and it worked.&amp;nbsp; After banging my head for a while against the monitor I decided to try one last thing before a break...RESTART ArcMap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then get back to Python and tried again...IT WORKED!!! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/shocked.png" /&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/plain.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't really know what happened, but Tom's suggestion make me try using the string value for the subtype instead of the number and it worked.&amp;nbsp; The final code is like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel (&amp;nbsp; [CATEGORIA],[NUM_CATASTRO], [PARCEL_SP] ):
&amp;nbsp; if [CATEGORIA] =='N/A':
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp; [NUM_CATASTRO]
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;CLR red='255'&amp;gt;&amp;lt;FNT size = '10'&amp;gt;" +&amp;nbsp; [CATEGORIA] + "&amp;lt;/FNT&amp;gt;&amp;lt;/CLR&amp;gt; &amp;lt;CLR blue='255'&amp;gt; \n" + [PARCEL_SP] + "&amp;lt;/CLR&amp;gt;"&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Find it weird that I needed to use the description instead of the integer value for the subtype field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for the help and suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:12:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730935#M56723</guid>
      <dc:creator>Ulises</dc:creator>
      <dc:date>2021-12-12T07:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning labels</title>
      <link>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730936#M56724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ulises,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perfect!&amp;nbsp; Glad that worked for you!&amp;nbsp; Please mark the answer as correct too!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 21:06:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conditioning-labels/m-p/730936#M56724</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2015-02-10T21:06:41Z</dc:date>
    </item>
  </channel>
</rss>

