<?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 Calculate statistics based on multiple fields in same layer in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/calculate-statistics-based-on-multiple-fields-in/m-p/1554575#M10445</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I'm trying to make a simple algebraic calculation based on multiple fields from the same data layer, specifically, to divide one field by another. A hitch, perhaps, is that I need the input to this calculation to be filterable by multiple selectors from within the Dashboard, i.e. month, year, and/or location, so I don't want to group by any of these options.&amp;nbsp;&lt;SPAN&gt;I need the resulting info to be used in both an indicator and in multiple charts.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I saw something similar on GitHub,&amp;nbsp;&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard/dashboard_data/CalculationAcrossFields.md" target="_self"&gt;https://github.com/Esri/arcade-expressions/blob/master/dashboard/dashboard_data/CalculationAcrossFields.md&lt;/A&gt;&amp;nbsp;, and mimicked that...but it doesn't work (and I don't quite understand Dictionaries, either, I have to admit). I get "&lt;SPAN&gt;&lt;EM&gt;Test execution error: Execution error - Invalid parameter. Verify test data.&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Any thoughts would be greatly appreciated. Thank you!&lt;/P&gt;&lt;LI-CODE lang="c"&gt;//Divide two fields from the same layer
//Result must be filterable by multiple selectors within the Dashboard
var portal = Portal('https://arcgis.com');

var fs = FeatureSetByPortalItem(
    portal,
    '86ba934a1b4c4ff2ae8188a012256ffc',
    0,
    [
        'TotalSteelhead',
        'TotalTrips'
    ],
    false
);

var ratioDict = {
    'fields': {'name': 'CPUE', 'type': 'esriFieldTypeDouble'},
    'features':
    [{'attributes':
    {'CPUE': Round((SUM(fs,'TotalSteelhead')/SUM(fs,'TotalTrips')),2)}
    }]};

return FeatureSet(ratioDict)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Nov 2024 00:01:05 GMT</pubDate>
    <dc:creator>JanetBrewster1</dc:creator>
    <dc:date>2024-11-01T00:01:05Z</dc:date>
    <item>
      <title>Calculate statistics based on multiple fields in same layer</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/calculate-statistics-based-on-multiple-fields-in/m-p/1554575#M10445</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I'm trying to make a simple algebraic calculation based on multiple fields from the same data layer, specifically, to divide one field by another. A hitch, perhaps, is that I need the input to this calculation to be filterable by multiple selectors from within the Dashboard, i.e. month, year, and/or location, so I don't want to group by any of these options.&amp;nbsp;&lt;SPAN&gt;I need the resulting info to be used in both an indicator and in multiple charts.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I saw something similar on GitHub,&amp;nbsp;&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard/dashboard_data/CalculationAcrossFields.md" target="_self"&gt;https://github.com/Esri/arcade-expressions/blob/master/dashboard/dashboard_data/CalculationAcrossFields.md&lt;/A&gt;&amp;nbsp;, and mimicked that...but it doesn't work (and I don't quite understand Dictionaries, either, I have to admit). I get "&lt;SPAN&gt;&lt;EM&gt;Test execution error: Execution error - Invalid parameter. Verify test data.&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Any thoughts would be greatly appreciated. Thank you!&lt;/P&gt;&lt;LI-CODE lang="c"&gt;//Divide two fields from the same layer
//Result must be filterable by multiple selectors within the Dashboard
var portal = Portal('https://arcgis.com');

var fs = FeatureSetByPortalItem(
    portal,
    '86ba934a1b4c4ff2ae8188a012256ffc',
    0,
    [
        'TotalSteelhead',
        'TotalTrips'
    ],
    false
);

var ratioDict = {
    'fields': {'name': 'CPUE', 'type': 'esriFieldTypeDouble'},
    'features':
    [{'attributes':
    {'CPUE': Round((SUM(fs,'TotalSteelhead')/SUM(fs,'TotalTrips')),2)}
    }]};

return FeatureSet(ratioDict)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 00:01:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/calculate-statistics-based-on-multiple-fields-in/m-p/1554575#M10445</guid>
      <dc:creator>JanetBrewster1</dc:creator>
      <dc:date>2024-11-01T00:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate statistics based on multiple fields in same layer</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/calculate-statistics-based-on-multiple-fields-in/m-p/1554647#M10447</link>
      <description>&lt;P&gt;You do not need a data expression for this. You can use an Indicator with a reference field.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the sum of TotalSteelhead as the data source for your indicator.&lt;/P&gt;
&lt;P&gt;Add a reference with a type of statistic and use the sum of TotalTrips.&lt;/P&gt;
&lt;P&gt;On the Indicator tab, remove the value and reference placeholders.&lt;/P&gt;
&lt;P&gt;Click on the curly brackets and pick the {ratio}.&lt;/P&gt;
&lt;P&gt;For a full walkthrough follow the first method outlined &lt;A href="https://community.esri.com/t5/arcgis-dashboards-blog/dashboards-that-pop-indicator-hacks/ba-p/1362510" target="_self"&gt;here&lt;/A&gt;, except you don't even need to get into Advanced Formatting&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 12:05:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/calculate-statistics-based-on-multiple-fields-in/m-p/1554647#M10447</guid>
      <dc:creator>JenniferAcunto</dc:creator>
      <dc:date>2024-11-01T12:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate statistics based on multiple fields in same layer</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/calculate-statistics-based-on-multiple-fields-in/m-p/1554873#M10450</link>
      <description>&lt;P&gt;Jen -- this is great!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had not seen your Indicator hack before...I would never have figured this out on my own. It worked perfectly for my indicators, and the results adjusted as I used various selectors within the dashboard. YAHOO!!&lt;/P&gt;&lt;P&gt;However, my charts are the other 50% of this problem. Do you have any thoughts on how I could incorporate this calculation for my charts?&lt;/P&gt;&lt;P&gt;Thank you so much for your help!!&lt;/P&gt;&lt;P&gt;Janet&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 22:02:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/calculate-statistics-based-on-multiple-fields-in/m-p/1554873#M10450</guid>
      <dc:creator>JanetBrewster1</dc:creator>
      <dc:date>2024-11-01T22:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate statistics based on multiple fields in same layer</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/calculate-statistics-based-on-multiple-fields-in/m-p/1555193#M10452</link>
      <description>&lt;P&gt;I missed that you need this to work in other charts as well. You can only do something like this without using a Data Expression for elements that allow you to aggregate your data and use Advanced Formatting, so really just Indicators and Table elements. All other elements would require a data expression or a complete overhaul of your data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm a one trick pony with Arcade so data expressions aren't really in my wheelhouse.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 18:37:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/calculate-statistics-based-on-multiple-fields-in/m-p/1555193#M10452</guid>
      <dc:creator>JenniferAcunto</dc:creator>
      <dc:date>2024-11-04T18:37:57Z</dc:date>
    </item>
  </channel>
</rss>

