<?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: Help with Arcade expression in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142641#M51253</link>
    <description>&lt;P&gt;If I am understanding this correctly, you want the expression to return all colours whose value is equal to the maximum value. This could be a single colour, or multiple, if there are ties.&lt;/P&gt;&lt;P&gt;Finding the max value is easy enough:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var colour_values = [
    $feature.blue,
    $feature.green,
    $feature.yellow,
    $feature.orange,
    $feature.red
]

var max_val = Max(colour_values)&lt;/LI-CODE&gt;&lt;P&gt;But then once you get the value, what do you do with it?&lt;/P&gt;&lt;P&gt;A simple approach is to just get the index positions of the maximum values, then decode those back to the names. Matching values can be pushed to an array, and we can use &lt;STRONG&gt;Concatenate&lt;/STRONG&gt; to format the array as a nice string.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var top_colours = []

for (var v in colour_values){
    if (colour_values[v] == max_val){
        var colour_name = Decode(
            v,
            0, 'Blue',
            1, 'Green',
            2, 'Yellow',
            3, 'Orange',
            4, 'Red',
            ''
        )
        
        Push(top_colours, colour_name)
    }
}

return Concatenate(top_colours, ', ')&lt;/LI-CODE&gt;&lt;P&gt;Here's the output from manually entering your example values:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1644506718929.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33610iF233053E9AA8E521/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1644506718929.png" alt="jcarlson_1-1644506718929.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Feb 2022 15:25:28 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-02-10T15:25:28Z</dc:date>
    <item>
      <title>Help with Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142616#M51246</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am looking to create an arcade expression that compares values from multiple fields and returns the highest values.&lt;BR /&gt;However, some fields have identical values.&lt;/P&gt;&lt;P&gt;Hopefully my example below better explains the issue&lt;/P&gt;&lt;P&gt;The data layer might contain the following 5 colour fields. With corresponding values.&lt;/P&gt;&lt;P&gt;Blue&amp;nbsp; &amp;nbsp;Green&amp;nbsp; &amp;nbsp;Yellow&amp;nbsp; &amp;nbsp;Orange&amp;nbsp; &amp;nbsp;Red&lt;BR /&gt;&amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8&lt;/P&gt;&lt;P&gt;And what I would like returned is Green, Orange, Red&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated, thanks&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 16:11:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142616#M51246</guid>
      <dc:creator>JoshNock1</dc:creator>
      <dc:date>2022-02-10T16:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142641#M51253</link>
      <description>&lt;P&gt;If I am understanding this correctly, you want the expression to return all colours whose value is equal to the maximum value. This could be a single colour, or multiple, if there are ties.&lt;/P&gt;&lt;P&gt;Finding the max value is easy enough:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var colour_values = [
    $feature.blue,
    $feature.green,
    $feature.yellow,
    $feature.orange,
    $feature.red
]

var max_val = Max(colour_values)&lt;/LI-CODE&gt;&lt;P&gt;But then once you get the value, what do you do with it?&lt;/P&gt;&lt;P&gt;A simple approach is to just get the index positions of the maximum values, then decode those back to the names. Matching values can be pushed to an array, and we can use &lt;STRONG&gt;Concatenate&lt;/STRONG&gt; to format the array as a nice string.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var top_colours = []

for (var v in colour_values){
    if (colour_values[v] == max_val){
        var colour_name = Decode(
            v,
            0, 'Blue',
            1, 'Green',
            2, 'Yellow',
            3, 'Orange',
            4, 'Red',
            ''
        )
        
        Push(top_colours, colour_name)
    }
}

return Concatenate(top_colours, ', ')&lt;/LI-CODE&gt;&lt;P&gt;Here's the output from manually entering your example values:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1644506718929.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33610iF233053E9AA8E521/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1644506718929.png" alt="jcarlson_1-1644506718929.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 15:25:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142641#M51253</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-10T15:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142643#M51254</link>
      <description>&lt;P&gt;If you use the Max expression for numeric fields, the label will return the max value.&amp;nbsp; For example, in my cities feature class I have 2 numeric fields, Xcoord and Ycoord. If I type&amp;nbsp;Max($feature.Xcoord,$feature.Ycoord) for the expression, the label drawn on the map returns the highest value.&amp;nbsp; See this Esri Community &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/arcade-expression-that-returns-the-quot-maximum/td-p/345272" target="_self"&gt;response&lt;/A&gt; for more details.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 15:26:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142643#M51254</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2022-02-10T15:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142699#M51269</link>
      <description>&lt;P&gt;That worked wonders, thank you Josh&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 16:37:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142699#M51269</guid>
      <dc:creator>JoshNock1</dc:creator>
      <dc:date>2022-02-10T16:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142805#M51292</link>
      <description>&lt;P&gt;I had written code that worked, but I used an array formatted like this:&lt;/P&gt;&lt;P&gt;var myArray = ["Blue:"+$feature.Blue,"Yellow:"+$feature.Yellow...]&lt;/P&gt;&lt;P&gt;So the array looked like this example: ["Blue:2","Yellow:5","Green:9","Orange:9","Red:8"]&lt;/P&gt;&lt;P&gt;Using this method I had to use Left, and Right, Find, and Count functions to parse the array values, Yuck.&amp;nbsp;&lt;/P&gt;&lt;P&gt;That Decode function!&amp;nbsp; Wow what a game changer!&amp;nbsp; Not sure how I missed knowing about it, but that is very cool.&amp;nbsp; Thanks for that.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 19:22:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142805#M51292</guid>
      <dc:creator>KimberlyGarbade</dc:creator>
      <dc:date>2022-02-10T19:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142810#M51293</link>
      <description>&lt;P&gt;Decode is a great function to work into your expressions. Feels like every month or so there's an Arcade function that somehow I never learned about, and I realize I've been doing things inefficiently!&lt;/P&gt;&lt;P&gt;I'd thought about a slightly different way of approaching this issue using an array of dictionaries, actually, and your expression sort of looked like it.&lt;/P&gt;&lt;PRE&gt;var colours = [&lt;BR /&gt;  {colour:'Blue', value:3},&lt;BR /&gt;  {colour:'Green', value:5},&lt;BR /&gt;  ...&lt;BR /&gt;]&lt;/PRE&gt;&lt;P&gt;And then using array-specific functions to sort and filter.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 19:30:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/help-with-arcade-expression/m-p/1142810#M51293</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-10T19:30:51Z</dc:date>
    </item>
  </channel>
</rss>

