<?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 Extracting field names for second and third highest values in a row in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/extracting-field-names-for-second-and-third/m-p/1143625#M51403</link>
    <description>&lt;P&gt;Hi, I have managed to extract the highest, second and third highest value, aswell as the field name of the highest value in a row. However, I´m struggling to extract the field name of the second and third highest value in a row. I used the following python code to extract highest, second and third highest values, and field name of highest:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Highest value:&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;maxnum([!Field1!, !Field2!, !Field3!,…])&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;def maxnum(fields):&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;fields.sort()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return fields[-1]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Field name with the highest value:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;getMaxField(!Field1!,!Field2!,!Field3!)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;def getMaxField(v1, v2, v3, name1, name2, name3):&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;maxval = max(v1,v2,v3)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if maxval == v1:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return name1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if maxval == v2:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return name2&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return name3&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on how I can rewrite the code, or use a different code, to extract field names of second and third highest value?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Feb 2022 15:12:47 GMT</pubDate>
    <dc:creator>Veomm</dc:creator>
    <dc:date>2022-02-14T15:12:47Z</dc:date>
    <item>
      <title>Extracting field names for second and third highest values in a row</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/extracting-field-names-for-second-and-third/m-p/1143625#M51403</link>
      <description>&lt;P&gt;Hi, I have managed to extract the highest, second and third highest value, aswell as the field name of the highest value in a row. However, I´m struggling to extract the field name of the second and third highest value in a row. I used the following python code to extract highest, second and third highest values, and field name of highest:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Highest value:&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;maxnum([!Field1!, !Field2!, !Field3!,…])&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;def maxnum(fields):&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;fields.sort()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return fields[-1]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Field name with the highest value:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;getMaxField(!Field1!,!Field2!,!Field3!)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;def getMaxField(v1, v2, v3, name1, name2, name3):&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;maxval = max(v1,v2,v3)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if maxval == v1:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return name1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if maxval == v2:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return name2&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return name3&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on how I can rewrite the code, or use a different code, to extract field names of second and third highest value?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 15:12:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/extracting-field-names-for-second-and-third/m-p/1143625#M51403</guid>
      <dc:creator>Veomm</dc:creator>
      <dc:date>2022-02-14T15:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field names for second and third highest values in a row</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/extracting-field-names-for-second-and-third/m-p/1143636#M51405</link>
      <description>&lt;P&gt;By virtue of example to change max into something else&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# -- sort then slice
v1= 10
v2=3
v3=20
sorted([v1, v2, v3], reverse=True)
[20, 10, 3]
# -- now slice what you want
sorted([v1, v2, v3], reverse=True)[1:]
[10, 3]
# --
sorted([v1, v2, v3], reverse=False)[:-1]
[3, 10]
# -- you can put ranges on the limits eg [1:4] etc)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 14 Feb 2022 15:29:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/extracting-field-names-for-second-and-third/m-p/1143636#M51405</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-02-14T15:29:58Z</dc:date>
    </item>
  </channel>
</rss>

