<?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: Calculating New Values for Indicator Widget in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/calculating-new-values-for-indicator-widget/m-p/1188788#M6509</link>
    <description>&lt;P&gt;Data Expressions can be a bit much to wrap your head around if you're new to Arcade, but they're not terrible once you sort of understand how they work.&lt;/P&gt;&lt;P&gt;When you create your&amp;nbsp;&lt;STRONG&gt;ratioDict&lt;/STRONG&gt;, that's going to be the&amp;nbsp;&lt;EM&gt;entire FeatureSet&lt;/EM&gt; that you get out at the end. But initially, it's just a&amp;nbsp;&lt;EM&gt;dictionary&lt;/EM&gt;, which is why the examples all use&amp;nbsp;&lt;STRONG&gt;Text(dict)&lt;/STRONG&gt; to get it as a string, and&amp;nbsp;&lt;STRONG&gt;FeatureSet(string)&amp;nbsp;&lt;/STRONG&gt;to parse the text into a FeatureSet.&lt;/P&gt;&lt;P&gt;Because your&amp;nbsp;&lt;STRONG&gt;ratioDict&lt;/STRONG&gt; is just a dictionary, you can't use functions like Sum on it the way you could on a real FeatureSet.&lt;/P&gt;&lt;P&gt;However! If all you want is to calculate the sum of that calculation, you can use&amp;nbsp;&lt;STRONG&gt;GroupBy&lt;/STRONG&gt; on the original&amp;nbsp;&lt;STRONG&gt;fs&lt;/STRONG&gt; FeatureSet. GroupBy returns a FeatureSet, so you don't have to bother with a dictionary at all.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal('https://www.arcgis.com');
var fs = FeatureSetByPortalItem(
    portal,
    '9ad3138c16dd4c20aca6ca2a1b14dc89',
    9,
    [
        'LEAKRATE',
        'LeakDays'
    ],
    false
);

return GroupBy(
    fs,
    'objectid',
    {
        name: 'leak_amount',
        expression: 'LEAKRATE * LeakDays',
        statistic: 'SUM'
    }
)&lt;/LI-CODE&gt;&lt;P&gt;Mind, this expression will return a FeatureSet that is the same length as the input, but with a newly calculated field&amp;nbsp;&lt;STRONG&gt;leak_amount&lt;/STRONG&gt;. Since you're using an Indicator, you can just apply the&amp;nbsp;&lt;STRONG&gt;Sum&lt;/STRONG&gt; there, instead of shoehorning it into the expression.&lt;/P&gt;&lt;P&gt;The benefit of doing it this way, too, is that keeping the output FeatureSet with the objectID intact will make it so that your indicator can interact with other elements of your Dashboard.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jul 2022 16:01:14 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-07-01T16:01:14Z</dc:date>
    <item>
      <title>Calculating New Values for Indicator Widget</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/calculating-new-values-for-indicator-widget/m-p/1188787#M6508</link>
      <description>&lt;P&gt;I'm wondering if I could get some help making an indicator widget that would dynamically calculate the sum of the product of two fields. Particularly, the product of a water mains leak rate and leak time, then sum each product to get a cumulative leak loss. Here's what I have so far, I'm not very familiar with Arcade, so forgive me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal('https://www.arcgis.com');
var fs = FeatureSetByPortalItem(
    portal,
    '9ad3138c16dd4c20aca6ca2a1b14dc89',
    9,
    [
        'LEAKRATE',
        'LeakDays'
    ],
    false
);

var ratioDict = { 
    'fields':
    {'name':'leaksum', 'type':'esriFieldTypeDouble'}, 
    'geometryType': '', 
    'features': 
    [{'attributes':
        {'leaksum': (fs, 'LEAKRATE') * (fs, 'LeakDays')
    }}]
};

return FeatureSet(SUM(ratioDict));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 15:48:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/calculating-new-values-for-indicator-widget/m-p/1188787#M6508</guid>
      <dc:creator>Calvin_Wong</dc:creator>
      <dc:date>2022-07-01T15:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating New Values for Indicator Widget</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/calculating-new-values-for-indicator-widget/m-p/1188788#M6509</link>
      <description>&lt;P&gt;Data Expressions can be a bit much to wrap your head around if you're new to Arcade, but they're not terrible once you sort of understand how they work.&lt;/P&gt;&lt;P&gt;When you create your&amp;nbsp;&lt;STRONG&gt;ratioDict&lt;/STRONG&gt;, that's going to be the&amp;nbsp;&lt;EM&gt;entire FeatureSet&lt;/EM&gt; that you get out at the end. But initially, it's just a&amp;nbsp;&lt;EM&gt;dictionary&lt;/EM&gt;, which is why the examples all use&amp;nbsp;&lt;STRONG&gt;Text(dict)&lt;/STRONG&gt; to get it as a string, and&amp;nbsp;&lt;STRONG&gt;FeatureSet(string)&amp;nbsp;&lt;/STRONG&gt;to parse the text into a FeatureSet.&lt;/P&gt;&lt;P&gt;Because your&amp;nbsp;&lt;STRONG&gt;ratioDict&lt;/STRONG&gt; is just a dictionary, you can't use functions like Sum on it the way you could on a real FeatureSet.&lt;/P&gt;&lt;P&gt;However! If all you want is to calculate the sum of that calculation, you can use&amp;nbsp;&lt;STRONG&gt;GroupBy&lt;/STRONG&gt; on the original&amp;nbsp;&lt;STRONG&gt;fs&lt;/STRONG&gt; FeatureSet. GroupBy returns a FeatureSet, so you don't have to bother with a dictionary at all.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal('https://www.arcgis.com');
var fs = FeatureSetByPortalItem(
    portal,
    '9ad3138c16dd4c20aca6ca2a1b14dc89',
    9,
    [
        'LEAKRATE',
        'LeakDays'
    ],
    false
);

return GroupBy(
    fs,
    'objectid',
    {
        name: 'leak_amount',
        expression: 'LEAKRATE * LeakDays',
        statistic: 'SUM'
    }
)&lt;/LI-CODE&gt;&lt;P&gt;Mind, this expression will return a FeatureSet that is the same length as the input, but with a newly calculated field&amp;nbsp;&lt;STRONG&gt;leak_amount&lt;/STRONG&gt;. Since you're using an Indicator, you can just apply the&amp;nbsp;&lt;STRONG&gt;Sum&lt;/STRONG&gt; there, instead of shoehorning it into the expression.&lt;/P&gt;&lt;P&gt;The benefit of doing it this way, too, is that keeping the output FeatureSet with the objectID intact will make it so that your indicator can interact with other elements of your Dashboard.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 16:01:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/calculating-new-values-for-indicator-widget/m-p/1188788#M6509</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-07-01T16:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating New Values for Indicator Widget</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/calculating-new-values-for-indicator-widget/m-p/1188791#M6510</link>
      <description>&lt;P&gt;Josh,&lt;/P&gt;&lt;P&gt;This is exactly what I'm looking for! Thank you! I do all of my automation in python and arcpy so trying to wrap my head around Arcade is challenging.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 16:12:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/calculating-new-values-for-indicator-widget/m-p/1188791#M6510</guid>
      <dc:creator>Calvin_Wong</dc:creator>
      <dc:date>2022-07-01T16:12:52Z</dc:date>
    </item>
  </channel>
</rss>

