<?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 Create indicator that shows value and percentile rank in Dashboards in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/create-indicator-that-shows-value-and-percentile/m-p/1538700#M10281</link>
    <description>&lt;P&gt;Hello -&lt;/P&gt;&lt;P&gt;I am working in ArcGIS Dashboards in ArcGIS online. I want to create an indicator (see example below) that will display the risk value (PR_EXHYDPAR)&amp;nbsp; stored in the layer as the middle text, and the percentile rank associated with that value which is not stored in the layer as the bottom text. I am trying write arcade code within the Indicator Advanced Formatting option that will order the PR_EXHYDPAR field and create a var for rank, and then calculate percentile rank to use in the bottom text. Below is what I have so far but it says "Unable to execute Arcade script", but is not showing any errors. I am not very familiar with iterate statements so guessing there is an issue there. Thanks in advance for any suggestions.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// order the layer by existing hydraulic risk
var ordered = OrderBy("PR_EXHYDPAR DESC")

//rank projects by existing hydraulic risk
var rank = 0
// iterate over the ordered layer
for(var f in ordered) {
    // increase the rank
    rank++
    }

//calculate percentile rank for existing hydraulic risk
var pctrank = (f.rank-1)/(Count($datapoint.OBJECTID)-1)

return {
  textColor:'black',
  topText: 'Existing Hydraulic Risk',
  topTextMaxSize: 'medium',
  middleText: $datapoint.PR_EXHYDPAR,
  middleTextMaxSize: 'large',
  bottomText: pctrank,
  bottomTextMaxSize: 'medium',

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture100.png" style="width: 272px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/115129i97E2E6801F108DFA/image-dimensions/272x194?v=v2" width="272" height="194" role="button" title="Picture100.png" alt="Picture100.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Sep 2024 20:36:22 GMT</pubDate>
    <dc:creator>LJackson29</dc:creator>
    <dc:date>2024-09-14T20:36:22Z</dc:date>
    <item>
      <title>Create indicator that shows value and percentile rank in Dashboards</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/create-indicator-that-shows-value-and-percentile/m-p/1538700#M10281</link>
      <description>&lt;P&gt;Hello -&lt;/P&gt;&lt;P&gt;I am working in ArcGIS Dashboards in ArcGIS online. I want to create an indicator (see example below) that will display the risk value (PR_EXHYDPAR)&amp;nbsp; stored in the layer as the middle text, and the percentile rank associated with that value which is not stored in the layer as the bottom text. I am trying write arcade code within the Indicator Advanced Formatting option that will order the PR_EXHYDPAR field and create a var for rank, and then calculate percentile rank to use in the bottom text. Below is what I have so far but it says "Unable to execute Arcade script", but is not showing any errors. I am not very familiar with iterate statements so guessing there is an issue there. Thanks in advance for any suggestions.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// order the layer by existing hydraulic risk
var ordered = OrderBy("PR_EXHYDPAR DESC")

//rank projects by existing hydraulic risk
var rank = 0
// iterate over the ordered layer
for(var f in ordered) {
    // increase the rank
    rank++
    }

//calculate percentile rank for existing hydraulic risk
var pctrank = (f.rank-1)/(Count($datapoint.OBJECTID)-1)

return {
  textColor:'black',
  topText: 'Existing Hydraulic Risk',
  topTextMaxSize: 'medium',
  middleText: $datapoint.PR_EXHYDPAR,
  middleTextMaxSize: 'large',
  bottomText: pctrank,
  bottomTextMaxSize: 'medium',

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture100.png" style="width: 272px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/115129i97E2E6801F108DFA/image-dimensions/272x194?v=v2" width="272" height="194" role="button" title="Picture100.png" alt="Picture100.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2024 20:36:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/create-indicator-that-shows-value-and-percentile/m-p/1538700#M10281</guid>
      <dc:creator>LJackson29</dc:creator>
      <dc:date>2024-09-14T20:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create indicator that shows value and percentile rank in Dashboards</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/create-indicator-that-shows-value-and-percentile/m-p/1538887#M10286</link>
      <description>&lt;P&gt;An indicator's advanced formatting area doesn't have access to the source data in a way to actually execute this expression. What you'd need instead is to use a Data Expression to create an ad-hoc "layer", and calculate your percentiles there.&lt;/P&gt;&lt;P&gt;Is your indicator showing percentiles for a selected feature?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 13:41:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/create-indicator-that-shows-value-and-percentile/m-p/1538887#M10286</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-09-16T13:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create indicator that shows value and percentile rank in Dashboards</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/create-indicator-that-shows-value-and-percentile/m-p/1538905#M10287</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;I was worried about that. I have put together the below data expression in the code box to select the fields I need from the layer and it works. I can use the below code in Pro to calculate rank, but not sure how to incorporate it into the Dashboard Data Expression. I would prefer to do this on the fly than add additional fields to my layer (There are 7 fields I need to create percentile ranks for).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var setfeatures = FeatureSetByName($datastore, "SNP_Project");&lt;/P&gt;&lt;P&gt;var ordered = OrderBy(setfeatures, 'PR_EXHYPDAR DESC')&lt;/P&gt;&lt;P&gt;var rank = 0&lt;BR /&gt;for(var f in ordered) {&lt;BR /&gt;rank++&lt;BR /&gt;if(f.OBJECTID == $feature.OBJECTID) {&lt;BR /&gt;return rank&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Can anyone provide guidance on how to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var port = Portal('https://www.arcgis.com');
var fs = filter(FeatureSetByPortalItem(
  port,'01610f3a8912467c8b06f4b223a6b5e1', 0,
  ['PROJECTID', 'PR_PROJNAME', 'PR_STATUS', 'PR_ORIGTOTCOST', 'PR_P6TOTCOST', 'PR_EXHYDPAR', 'PR_EXSTRPAR', 'PR_EXTOTPAR', 'PR_ALTHYDPAR', 'PR_ALTSTRPAR', 'PR_ALTTOTPAR', 'PR_REDHYDPAR', 'PR_REDSTRPAR', 'PR_REDTOTPAR', 'PR_TOTNOMSCORE', 'PR_TOTSCORE',  'PR_WAC', 'PR_SUBWATERSHED', 'PR_COMMUNITY1', 'PR_MODELDATE', 'PR_PARTOOLDATE', 'PR_SWIM_ONLY', 'PR_PART_ONLY', 'PR_NONDISTRICT', 'PR_STRPARDATE'], 
  false),
  "PR_SWIM_ONLY='No' AND PR_PART_ONLY='No' AND  PR_NONDISTRICT='No' AND (PR_STATUS='01. Submitted – Pending Review/Scoring' OR PR_STATUS='02. Scored' OR PR_STATUS='03. Advanced SW Planning' OR PR_STATUS='04. Design' OR PR_STATUS='05. Construction' OR PR_STATUS='07. Completed')"
);

var out_dict = {
    fields: [
        {name: 'projectid', type: 'esriFieldTypeString'},
        {name: 'projname', type: 'esriFieldTypeString'},
        {name: 'status', type: 'esriFieldTypeString'},
        {name: 'origtotcost', type: 'esriFieldTypeDouble'},
        {name: 'P6totcost', type: 'esriFieldTypeDouble'},
        {name: 'exhydpar', type: 'esriFieldTypeDouble'},
        {name: 'exstrpar', type: 'esriFieldTypeDouble'},
        {name: 'extotpar', type: 'esriFieldTypeDouble'},
        {name: 'althydpar', type: 'esriFieldTypeDouble'},
        {name: 'altstrpar', type: 'esriFieldTypeDouble'},
        {name: 'alttotpar', type: 'esriFieldTypeDouble'},
        {name: 'redhydpar', type: 'esriFieldTypeDouble'},
        {name: 'redstrpar', type: 'esriFieldTypeDouble'},
        {name: 'redtotpar', type: 'esriFieldTypeDouble'},
        {name: 'totnomscore', type: 'esriFieldTypeInteger'},
        {name: 'totscore', type: 'esriFieldTypeDouble'},        
        {name: 'wac', type: 'esriFieldTypeString'},
        {name: 'subwatershed', type: 'esriFieldTypeString'},
        {name: 'community1', type: 'esriFieldTypeString'},
        {name: 'modeldate', type: 'esriFieldTypeDate'},
        {name: 'partooldate', type: 'esriFieldTypeDate'},
        {name: 'strpardate', type: 'esriFieldTypeDate'},        
        {name: 'swimonly', type: 'esriFieldTypeString'},
        {name: 'partonly', type: 'esriFieldTypeString'},
        {name: 'nondistr', type: 'esriFieldTypeString'},
     ],
    geometryType: '',
    features: []
}

// Iterate over each feature in the layer
for (var f in fs){
    
    Push(
        out_dict['features'],
        {attributes:
            {
                projectid: Text(f['PROJECTID']),
                projname: Text(f['PR_PROJNAME']),
                status: Text(f['PR_STATUS']),
                origtotcost: Number(f['PR_ORIGTOTCOST']),
                P6totcost: Number(f['PR_P6TOTCOST']),
                exhydpars: Number(f['PR_EXHYDPAR']),
                exstrpar: Number(f['PR_EXSTRPAR']),
                extotpar: Number(f['PR_EXTOTPAR']),
                althydpar: Number(f['PR_ALTHYDPAR']),
                altstrpar: Number(f['PR_ALTSTRPAR']),
                alttotpar: Number(f['PR_ALTTOTPAR']),
                redhydpar: Number(f['PR_REDHYDPAR']),
                redstrpar: Number(f['PR_REDSTRPAR']),
                redtotpar: Number(f['PR_REDTOTPAR']),
                totnomscore: Number(f['PR_TOTNOMSCORE']),
                totscore: Number(f['PR_TOTSCORE']),
                wac: Text(f['PR_WAC']),
                subwatershed: Text(f['PR_SUBWATERSHED']),
                community1: Text(f['PR_COMMUNITY1']),
                modeldate: Date(f['PR_MODELDATE']),
                partooldate: Date(f['PR_PARTOOLDATE']),
                strpardate: Date(f['PR_STRPARDATE']),
                swimonly: Text(f['PR_SWIM_ONLY']),
                partonly: Text(f['PR_PART_ONLY']),
                nondistr: Text(f['PR_NONDISTRICT']),
                            }
        }
    )
}

//Return populated out_dict as FeatureSet
var par = FeatureSet(Text(out_dict))

return par&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 16:50:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/create-indicator-that-shows-value-and-percentile/m-p/1538905#M10287</guid>
      <dc:creator>LJackson29</dc:creator>
      <dc:date>2024-09-19T16:50:52Z</dc:date>
    </item>
  </channel>
</rss>

