<?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: Data expression that takes two numeric fields and calculates percentage change in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1666272#M11636</link>
    <description>&lt;P&gt;You can use the GroupBy function to calculate this&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(
  Portal("https://www.arcgis.com"),
  "yourID",
  0,
  ['County','Year', 'curr_enr','prev_enr'],
 false
)
GroupBy(fs, ['County','Year','curr_enr','prev_enr'], {name: 'Change', expression: '(curr_enr - prev_enr)/prev_enr', statistic: 'Max'})&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 17 Nov 2025 15:23:06 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2025-11-17T15:23:06Z</dc:date>
    <item>
      <title>Data expression that takes two numeric fields and calculates percentage change</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1666043#M11631</link>
      <description>&lt;P&gt;I have a feature layer containing several years of school enrollment data by county. Among the fields are current year enrollment (curr_enr) and previous year enrollment (prev_enr).&lt;/P&gt;&lt;P&gt;Using those fields, I want to calculate percentage change and display that value in a dashboard serial chart. That is, ($feature.curr_enr-$.prev_enr)/$feature.prev_enr&lt;/P&gt;&lt;P&gt;Based on other posts, it seems that my plan -- a dashboard serial chart showing percentage change by year -- requires a data expression.&lt;/P&gt;&lt;P&gt;I've created a variable for my source feature layer. But I'm stuck on how to calculate percentage change from the two enrollment fields and returning that value to show on the serial chart. (Once created, the serial chart would be controlled by a county selector.) Thank you for any pointers.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2025 21:48:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1666043#M11631</guid>
      <dc:creator>JimMiller3</dc:creator>
      <dc:date>2025-11-14T21:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Data expression that takes two numeric fields and calculates percentage change</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1666269#M11635</link>
      <description>&lt;P&gt;Something like this should get you started.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(
    Portal("https://www.arcgis.com"),
    "&amp;lt;itemID&amp;gt;",
    &amp;lt;layerIndex&amp;gt;,
    ["County", "Year", "curr_enr", "prev_enr"],
    false
);

var features = [];

for (var f in fs) {
    var county = f["County"];
    var year = f["Year"];
    var curr = f["curr_enr"];
    var prev = f["prev_enr"];

    if (IsEmpty(curr) || IsEmpty(prev) || prev == 0) {
        continue;
    }

    var pctChange = ((curr - prev) / prev) * 100;

    Push(features, {
        attributes: {
            County: county,
            Year: year,
            PercentChange: pctChange
        }
    });
}

return FeatureSet(Text({
    fields: [
        { name: "County", type: "esriFieldTypeString" },
        { name: "Year", type: "esriFieldTypeInteger" },
        { name: "PercentChange", type: "esriFieldTypeDouble" }
    ],
    geometryType: "",
    features: features
}));&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Nov 2025 14:56:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1666269#M11635</guid>
      <dc:creator>Neal_t_k</dc:creator>
      <dc:date>2025-11-17T14:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Data expression that takes two numeric fields and calculates percentage change</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1666272#M11636</link>
      <description>&lt;P&gt;You can use the GroupBy function to calculate this&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(
  Portal("https://www.arcgis.com"),
  "yourID",
  0,
  ['County','Year', 'curr_enr','prev_enr'],
 false
)
GroupBy(fs, ['County','Year','curr_enr','prev_enr'], {name: 'Change', expression: '(curr_enr - prev_enr)/prev_enr', statistic: 'Max'})&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Nov 2025 15:23:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1666272#M11636</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-11-17T15:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Data expression that takes two numeric fields and calculates percentage change</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1666276#M11637</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;I need to learn groupby better, much shorter, and all at once.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2025 15:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1666276#M11637</guid>
      <dc:creator>Neal_t_k</dc:creator>
      <dc:date>2025-11-17T15:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Data expression that takes two numeric fields and calculates percentage change</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1667761#M11656</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/763693"&gt;@Neal_t_k&lt;/a&gt;&amp;nbsp;and &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;for the above responses. Both suggestions work perfectly if I select any of California’s 58 counties.&lt;/P&gt;&lt;P&gt;Problems occur when the county selector is set to “None.” In that case, three serial charts update: 1) cumulative enrollment by year for all of California's counties; 2) cumulative enrollment change by year for all of California's counties and 3) cumulative enrollment percentage change by year for all of California's counties.&lt;/P&gt;&lt;P&gt;The percentage change values are incorrect.&lt;/P&gt;&lt;P&gt;For example, the image below shows 2023-24 to 2024-25 percentage change on the serial chart and in an indicator using the percentage change calculated value. The percentage change value in the indicator card - -0.54% -- is correct. The percentage change value in the serial chart – 2.97% -- is incorrect.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JimMiller3_0-1763703214566.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/144238i64D8D1353025B5C4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JimMiller3_0-1763703214566.png" alt="JimMiller3_0-1763703214566.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Below is how things appear in the serial chart setup. I suspect the problem stems from the Statistic selection. It currently shows “Maximum” but any option I choose – Average, Minimum, etc. -- yields incorrect values. Is there a way to show percentage change value as is, without applying a statistic type to it? Or is there another approach to take. Thanks.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JimMiller3_1-1763703326555.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/144239i4EE63F33FE74D7C6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JimMiller3_1-1763703326555.png" alt="JimMiller3_1-1763703326555.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Nov 2025 05:40:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1667761#M11656</guid>
      <dc:creator>JimMiller3</dc:creator>
      <dc:date>2025-11-21T05:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Data expression that takes two numeric fields and calculates percentage change</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1667858#M11658</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/366452"&gt;@JimMiller3&lt;/a&gt;&amp;nbsp; &amp;nbsp;Did you try "Sum" percent change? How do you have it calculated in the indicator?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Nov 2025 14:00:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1667858#M11658</guid>
      <dc:creator>Neal_t_k</dc:creator>
      <dc:date>2025-11-21T14:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Data expression that takes two numeric fields and calculates percentage change</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1668717#M11666</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/763693"&gt;@Neal_t_k&lt;/a&gt;&amp;nbsp;If I change the Statistic selection to "Sum" for the serial chart, it displays -13.53%. That is incorrect. It is the sum of the 58 counties' respective percentage changes from 2023-24 to 2024-25, and not the cumulative percentage change for the state as a whole (which is the expected value.)&lt;/P&gt;&lt;P&gt;The indicator works as expected: It&amp;nbsp;sums up curr_enr and prev_enr values in the Data section. In the Indicator, section, I choose "Percent Change" calculated values (images below.) I get the correct percentage change whether one county, 10 counties, or no county is selected.&lt;/P&gt;&lt;P&gt;So, in essence, what I want to do using a data expression or other approach is to show the same kind of calculation, by year, in a serial chart.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JimMiller3_1-1764138409547.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/144447i84C15D182640718A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JimMiller3_1-1764138409547.png" alt="JimMiller3_1-1764138409547.png" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JimMiller3_0-1764137980273.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/144446i7DEE0AD9DD2B89E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JimMiller3_0-1764137980273.png" alt="JimMiller3_0-1764137980273.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2025 15:51:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1668717#M11666</guid>
      <dc:creator>JimMiller3</dc:creator>
      <dc:date>2025-11-26T15:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Data expression that takes two numeric fields and calculates percentage change</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1668847#M11667</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/366452"&gt;@JimMiller3&lt;/a&gt;&amp;nbsp;I am not sure how to fix this, they are calculating different things.&amp;nbsp; Your chart is calculating the sum of the calculated year to year percent change.&amp;nbsp; &amp;nbsp;Where as the indicator is adding up all the current years enrollment and then all the previous years enrollment and the calculating the percent change from those totals&amp;nbsp; e.g.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Neal_t_k_0-1764173902615.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/144463i5A17E362483F378E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Neal_t_k_0-1764173902615.png" alt="Neal_t_k_0-1764173902615.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It appears the indicator is calculating correctly, while the serial table is only calculating correctly for the selected counties and only when a single year is selected...I don't know what the solution is for this, other than being selective on what and how you show the data.&amp;nbsp; Maybe don't show percent change in the serial chart and only show current enrollment, then set a chart action to filter the indicator on selection of one of the columns in the chart.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2025 17:15:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1668847#M11667</guid>
      <dc:creator>Neal_t_k</dc:creator>
      <dc:date>2025-11-26T17:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Data expression that takes two numeric fields and calculates percentage change</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1669969#M11672</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/763693"&gt;@Neal_t_k&lt;/a&gt;. A colleague and I are continuing to experiment on this. This is the app as it now stands ("&lt;A href="https://dru-data-portal-cacensus.hub.arcgis.com/apps/7fb99fb05b4c4fb6a19e70d7b827d9d2/explore" target="_self"&gt;State and County Projected Enrollment&lt;/A&gt;").&lt;/P&gt;&lt;P&gt;A possible percentage change-by-year approach we're tinkering with arose&amp;nbsp;from this &lt;A href="https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-calculate-the-percentage-of/m-p/1127993/highlight/true#M5523" target="_self"&gt;solution&lt;/A&gt; by&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;The correct multi-county percentage change values show in the data expression console. However, the values displayed in the serial chart are off. Our guess is that the Statistic selection in the serial chart configuration (whatever option is selected) again is throwing things off.&lt;/P&gt;&lt;P&gt;Percentage change charts help show trends over time.&amp;nbsp;It would be great if Esri could add a Percentage Change calculation to the eight other options in the Serial Chart statistics dropdown.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Dec 2025 20:18:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-that-takes-two-numeric-fields-and/m-p/1669969#M11672</guid>
      <dc:creator>JimMiller3</dc:creator>
      <dc:date>2025-12-03T20:18:17Z</dc:date>
    </item>
  </channel>
</rss>

