<?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 Arcade Expression for Dominant Category in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-dominant-category/m-p/1318714#M53922</link>
    <description>&lt;P&gt;I am symbolizing a crime layer by Predominant Category in ArcGIS Online and I am trying to create an Arcade expression in the Pop-up configuration that displays&amp;nbsp; dominant field (Property Crime or Personal Crime).&amp;nbsp; How would I write a script to say "Dominant Type:" followed by the dominant field?&lt;/P&gt;</description>
    <pubDate>Tue, 15 Aug 2023 15:17:10 GMT</pubDate>
    <dc:creator>RobertCox87</dc:creator>
    <dc:date>2023-08-15T15:17:10Z</dc:date>
    <item>
      <title>Arcade Expression for Dominant Category</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-dominant-category/m-p/1318714#M53922</link>
      <description>&lt;P&gt;I am symbolizing a crime layer by Predominant Category in ArcGIS Online and I am trying to create an Arcade expression in the Pop-up configuration that displays&amp;nbsp; dominant field (Property Crime or Personal Crime).&amp;nbsp; How would I write a script to say "Dominant Type:" followed by the dominant field?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 15:17:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-dominant-category/m-p/1318714#M53922</guid>
      <dc:creator>RobertCox87</dc:creator>
      <dc:date>2023-08-15T15:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression for Dominant Category</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-dominant-category/m-p/1318953#M53938</link>
      <description>&lt;P&gt;Hi Robert - I did a similar thing with Arcade (using a sample that I can't find the source of right now - apologies to the author).&amp;nbsp; I did "Top 5", you could change the first line to = 1 to just get the top one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a screenshot of the popup and the code.&amp;nbsp; The only bug / issue at the moment is that equal ranks / scores are all showing up - I would prefer it to just take the first one in that case.&lt;/P&gt;&lt;P&gt;Screenshots below...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Michael_Kraus_0-1692142283390.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/78163i4EC068143E39FDD5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Michael_Kraus_0-1692142283390.png" alt="Michael_Kraus_0-1692142283390.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Example with equal ranks:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Michael_Kraus_1-1692142335763.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/78164i349405A78F323D39/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Michael_Kraus_1-1692142335763.png" alt="Michael_Kraus_1-1692142335763.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code below....&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var numTopValues = 5;&lt;/P&gt;&lt;P&gt;var groups = [&lt;BR /&gt;&lt;BR /&gt;{ value: $feature["P_Afghanistan_Tot"], alias: "Afghanistan"},&lt;BR /&gt;{ value: $feature["P_Bangladesh_Tot"], alias: "Bangladesh"},&lt;BR /&gt;{ value: $feature["P_Bosnia_Herzegov_Tot"], alias: "Bosnia and Herzegovina"},&lt;BR /&gt;{ value: $feature["P_Brazil_Tot"], alias: "Brazil"},&lt;BR /&gt;{ value: $feature["P_Cambodia_Tot"], alias: "Cambodia"},&lt;BR /&gt;{ value: $feature["P_Canada_Tot"], alias: "Canada"},&lt;BR /&gt;{ value: $feature["P_Chile_Tot"], alias: "Chile"},&lt;BR /&gt;{ value: $feature["P_China_Tot"], alias: "China"},&lt;BR /&gt;{ value: $feature["P_Croatia_Tot"], alias: "Croatia"},&lt;BR /&gt;{ value: $feature["P_Egypt_Tot"], alias: "Egypt"},&lt;BR /&gt;{ value: $feature["P_England_Tot"], alias: "England"},&lt;BR /&gt;{ value: $feature["P_Fiji_Tot"], alias: "Fiji"},&lt;BR /&gt;{ value: $feature["P_France_Tot"], alias: "France"},&lt;BR /&gt;{ value: $feature["P_Germany_Tot"], alias: "Germany"},&lt;BR /&gt;{ value: $feature["P_Greece_Tot"], alias: "Greece"},&lt;BR /&gt;{ value: $feature["P_Hong_Kong_SAR_Ch_Tot"], alias: "Hong Kong"},&lt;BR /&gt;{ value: $feature["P_India_Tot"], alias: "India"},&lt;BR /&gt;{ value: $feature["P_Indonesia_Tot"], alias: "Indonesia"},&lt;BR /&gt;{ value: $feature["P_Iran_Tot"], alias: "Iran"},&lt;BR /&gt;{ value: $feature["P_Iraq_Tot"], alias: "Iraq"},&lt;BR /&gt;{ value: $feature["P_Ireland_Tot"], alias: "Ireland"},&lt;BR /&gt;{ value: $feature["P_Italy_Tot"], alias: "Italy"},&lt;BR /&gt;{ value: $feature["P_Japan_Tot"], alias: "Japan"},&lt;BR /&gt;{ value: $feature["P_Korea_South_Tot"], alias: "South Korea"},&lt;BR /&gt;{ value: $feature["P_Lebanon_Tot"], alias: "Lebanon"},&lt;BR /&gt;{ value: $feature["P_Malaysia_Tot"], alias: "Malaysia"},&lt;BR /&gt;{ value: $feature["P_Malta_Tot"], alias: "Malta"},&lt;BR /&gt;{ value: $feature["P_Mauritius_Tot"], alias: "Mauritius"},&lt;BR /&gt;{ value: $feature["P_Myanmar_Tot"], alias: "Myanmar"},&lt;BR /&gt;{ value: $feature["P_Nepal_Tot"], alias: "Nepal"},&lt;BR /&gt;{ value: $feature["P_Netherlands_Tot"], alias: "Netherlands"},&lt;BR /&gt;{ value: $feature["P_New_Zealand_Tot"], alias: "New Zealand"},&lt;BR /&gt;{ value: $feature["P_Pakistan_Tot"], alias: "Pakistan"},&lt;BR /&gt;{ value: $feature["P_PNG_Tot"], alias: "PNG"},&lt;BR /&gt;{ value: $feature["P_Philippines_Tot"], alias: "Philippines"},&lt;BR /&gt;{ value: $feature["P_Poland_Tot"], alias: "Poland"},&lt;BR /&gt;{ value: $feature["P_Scotland_Tot"], alias: "Scotland"},&lt;BR /&gt;{ value: $feature["P_Singapore_Tot"], alias: "Singapore"},&lt;BR /&gt;{ value: $feature["P_South_Africa_Tot"], alias: "South Africa"},&lt;BR /&gt;{ value: $feature["P_Sri_Lanka_Tot"], alias: "Sri Lanka"},&lt;BR /&gt;{ value: $feature["P_Taiwan_Tot"], alias: "Taiwan"},&lt;BR /&gt;{ value: $feature["P_Thailand_Tot"], alias: "Thailand"},&lt;BR /&gt;{ value: $feature["P_North_Macedonia_Tot"], alias: "North Macedonia"},&lt;BR /&gt;{ value: $feature["P_Turkey_Tot"], alias: "Turkey"},&lt;BR /&gt;{ value: $feature["P_USA_Tot"], alias: "USA"},&lt;BR /&gt;{ value: $feature["P_Vietnam_Tot"], alias: "Vietnam"},&lt;BR /&gt;{ value: $feature["P_Wales_Tot"], alias: "Wales"},&lt;BR /&gt;{ value: $feature["P_Zimbabwe_Tot"], alias: "Zimbabwe"}&lt;/P&gt;&lt;P&gt;// ADD MORE FIELDS AS NECESSARY&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;function getValuesArray(a){&lt;BR /&gt;var valuesArray = []&lt;BR /&gt;for(var i in a){&lt;BR /&gt;valuesArray[i] = a[i].value;&lt;BR /&gt;}&lt;BR /&gt;return valuesArray;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function findAliases(top5a,fulla){&lt;BR /&gt;var aliases = [];&lt;BR /&gt;var found = "";&lt;BR /&gt;for(var i in top5a){&lt;BR /&gt;for(var k in fulla){&lt;BR /&gt;if(top5a[i] == fulla[k].value &amp;amp;&amp;amp; Find(fulla[k].alias, found) == -1){&lt;BR /&gt;found += fulla[k].alias;&lt;BR /&gt;aliases[Count(aliases)] = {&lt;BR /&gt;alias: fulla[k].alias,&lt;BR /&gt;value: top5a[i]&lt;BR /&gt;};&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return aliases;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;function getTopGroups(groupsArray){&lt;BR /&gt;&lt;BR /&gt;var values = getValuesArray(groupsArray);&lt;BR /&gt;var top5Values = IIF(Max(values) &amp;gt; 0, Top(Reverse(Sort(values)),numTopValues), "Insufficient Population");&lt;BR /&gt;var top5Aliases = findAliases(top5Values,groupsArray);&lt;BR /&gt;&lt;BR /&gt;if(TypeOf(top5Values) == "String"){&lt;BR /&gt;return top5Values;&lt;BR /&gt;} else {&lt;BR /&gt;var content = "";&lt;BR /&gt;for(var i in top5Aliases){&lt;BR /&gt;content += (i+1) + ". " + top5Aliases[i].alias + " (" + Text(top5Aliases[i].value, "#,###") + ")";&lt;BR /&gt;content += IIF(i &amp;lt; numTopValues-1, TextFormatting.NewLine, "");&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;return content;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;getTopGroups(groups);&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 23:34:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-dominant-category/m-p/1318953#M53938</guid>
      <dc:creator>Michael_Kraus</dc:creator>
      <dc:date>2023-08-15T23:34:52Z</dc:date>
    </item>
  </channel>
</rss>

