<?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 Labeling Related Table - Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/labeling-related-table-python/m-p/437090#M34354</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working on a small project to label points based on a related table. I was able to get the labeling to work using this script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel([SIGN_ID]):
&amp;nbsp;&amp;nbsp;&amp;nbsp; strWhereClause = '"sign_ID" = \'{0}\''.format([SIGN_ID])
&amp;nbsp;&amp;nbsp;&amp;nbsp; strpTable = "agencies.DATA_ADMIN7.signs"
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = arcpy.da.SearchCursor(strpTable,"sign_order", strWhereClause)
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strLabel = str(row[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result += strLabel + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sort_fields = [["sign_order", "ASCENDING"]]
&amp;nbsp;&amp;nbsp;&amp;nbsp; return result.rstrip()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need to do now is sort the results of the labeling by a certain field (in ascending order). Currently, the labels are showing up based on objectID and display as 1,3,2, I need to have them show up based on a "sign_Order" field - 1,2,3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know how to sort the labels in this way?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Pat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 19:34:16 GMT</pubDate>
    <dc:creator>deleted-user-K_IRAXrpGKsG</dc:creator>
    <dc:date>2021-12-11T19:34:16Z</dc:date>
    <item>
      <title>Labeling Related Table - Python</title>
      <link>https://community.esri.com/t5/python-questions/labeling-related-table-python/m-p/437090#M34354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working on a small project to label points based on a related table. I was able to get the labeling to work using this script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel([SIGN_ID]):
&amp;nbsp;&amp;nbsp;&amp;nbsp; strWhereClause = '"sign_ID" = \'{0}\''.format([SIGN_ID])
&amp;nbsp;&amp;nbsp;&amp;nbsp; strpTable = "agencies.DATA_ADMIN7.signs"
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = arcpy.da.SearchCursor(strpTable,"sign_order", strWhereClause)
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strLabel = str(row[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result += strLabel + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sort_fields = [["sign_order", "ASCENDING"]]
&amp;nbsp;&amp;nbsp;&amp;nbsp; return result.rstrip()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need to do now is sort the results of the labeling by a certain field (in ascending order). Currently, the labels are showing up based on objectID and display as 1,3,2, I need to have them show up based on a "sign_Order" field - 1,2,3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know how to sort the labels in this way?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Pat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:34:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labeling-related-table-python/m-p/437090#M34354</guid>
      <dc:creator>deleted-user-K_IRAXrpGKsG</dc:creator>
      <dc:date>2021-12-11T19:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Labeling Related Table - Python</title>
      <link>https://community.esri.com/t5/python-questions/labeling-related-table-python/m-p/437091#M34355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See this blog on labeling with a related table. &lt;A href="https://community.esri.com/migration-blogpost/2492"&gt;Creating Labels with Related Table Data&lt;/A&gt;&amp;nbsp; Using this method you should be able to follow the dictionary with a list that you could sort and use the labels in the same way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2015 20:41:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/labeling-related-table-python/m-p/437091#M34355</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-08-24T20:41:48Z</dc:date>
    </item>
  </channel>
</rss>

