<?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: Cumulative Chart With Arcade Expression in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123644#M5449</link>
    <description>&lt;P&gt;If you look at the example expressions, calling &lt;STRONG&gt;combinedDict.features[i]&lt;/STRONG&gt; should be separate from &lt;STRONG&gt;i++&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Try putting &lt;STRONG&gt;i++&lt;/STRONG&gt; on its own line at the end of your for loop, and reference the index &lt;STRONG&gt;i&lt;/STRONG&gt;, not &lt;STRONG&gt;i++&lt;/STRONG&gt; when you are adding to the combinedDict.features array.&lt;/P&gt;&lt;P&gt;Alternatively, you could use &lt;STRONG&gt;Push&lt;/STRONG&gt; to populate an array, then supply that array when you create the &lt;STRONG&gt;combinedDict&lt;/STRONG&gt; object.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var features = []

for (var v in vendor){
    var feat = {
        attributes: {
            date1: v["Invoice_Date"],
            cost1: v["Invoice_Total"]
        }
    }
    Push(features, feat)
};

var combinedDict = {
    fields: [
        { name: "date1", type: "esriFieldTypeDate" },
        { name: "cost1", type: "esriFieldTypeDouble" },
    ],
    geometryType: "",
    features: features,
};&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 07 Dec 2021 23:01:16 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2021-12-07T23:01:16Z</dc:date>
    <item>
      <title>Cumulative Chart With Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123623#M5448</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am having trouble creating a cumulative chart for my dashboard using a modified arcade expression (see below).&amp;nbsp; &amp;nbsp;It doesn't give me an error or anything it just spits out this empty feature set.&amp;nbsp; Any help would be appreciated!&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;P&gt;var portal = Portal("&lt;A href="https://www.arcgis.com/" target="_blank"&gt;https://www.arcgis.com/&lt;/A&gt;");&lt;BR /&gt;var vendor = GroupBy(&lt;BR /&gt;FeatureSetByPortalItem(portal,"********************",0,["*"],false),&lt;BR /&gt;["Invoice_Date"],&lt;BR /&gt;[&lt;BR /&gt;{ name: "Invoice_Total", expression: "Invoice_Total", statistic: "SUM" }&lt;BR /&gt;]&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;var combinedDict = {&lt;BR /&gt;fields: [&lt;BR /&gt;{ name: "date1", type: "esriFieldTypeDate" },&lt;BR /&gt;{ name: "cost1", type: "esriFieldTypeDouble" },&lt;BR /&gt;],&lt;BR /&gt;geometryType: "",&lt;BR /&gt;features: [],&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var i = 0;&lt;BR /&gt;// Loop through each FeatureSet and store its attributes&lt;BR /&gt;for (var v in vendor) {&lt;BR /&gt;combinedDict.features[i++] = {&lt;BR /&gt;attributes: {&lt;BR /&gt;date1: "Invoice_Date",&lt;BR /&gt;cost1: v["Invoice_Total"],&lt;BR /&gt;},&lt;BR /&gt;};&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//return combinedDict;&lt;BR /&gt;// Return dictionary cast as a FeatureSet&lt;BR /&gt;return FeatureSet(Text(combinedDict));&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 22:30:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123623#M5448</guid>
      <dc:creator>JoshHabel</dc:creator>
      <dc:date>2021-12-07T22:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Chart With Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123644#M5449</link>
      <description>&lt;P&gt;If you look at the example expressions, calling &lt;STRONG&gt;combinedDict.features[i]&lt;/STRONG&gt; should be separate from &lt;STRONG&gt;i++&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Try putting &lt;STRONG&gt;i++&lt;/STRONG&gt; on its own line at the end of your for loop, and reference the index &lt;STRONG&gt;i&lt;/STRONG&gt;, not &lt;STRONG&gt;i++&lt;/STRONG&gt; when you are adding to the combinedDict.features array.&lt;/P&gt;&lt;P&gt;Alternatively, you could use &lt;STRONG&gt;Push&lt;/STRONG&gt; to populate an array, then supply that array when you create the &lt;STRONG&gt;combinedDict&lt;/STRONG&gt; object.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var features = []

for (var v in vendor){
    var feat = {
        attributes: {
            date1: v["Invoice_Date"],
            cost1: v["Invoice_Total"]
        }
    }
    Push(features, feat)
};

var combinedDict = {
    fields: [
        { name: "date1", type: "esriFieldTypeDate" },
        { name: "cost1", type: "esriFieldTypeDouble" },
    ],
    geometryType: "",
    features: features,
};&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 07 Dec 2021 23:01:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123644#M5449</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-12-07T23:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Chart With Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123727#M5450</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1638956304462.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/29094i8E37061BD8C97256/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1638956304462.png" alt="JohannesLindner_0-1638956304462.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1638956317482.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/29095i225B60230BE570FE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1638956317482.png" alt="JohannesLindner_1-1638956317482.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;you don't use quotation marks around the dictionary keys&lt;/LI&gt;&lt;LI&gt;you try to store the string "Invoice_Date" instead of the value of the&amp;nbsp;field Invoice_Date (even if you used the quotation marks correctly, this would get rejected, as the type of date1 is esriFieldTypeDate)&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal("https://www.arcgis.com/")
var vendor = GroupBy(
  FeatureSetByPortalItem(portal,"********************",0,["*"],false),
  ["Invoice_Date"],
  [
    { "name": "Invoice_Total", "expression": "Invoice_Total", "statistic": "SUM" }
  ]
)

var combinedDict = {
  "fields": [
    { "name": "date1", "type": "esriFieldTypeDate" },
    { "name": "cost1", "type": "esriFieldTypeDouble" },
  ],
  "geometryType": "",
  "features": []
}

var i = 0
// Loop through each FeatureSet and store its attributes
for (var v in vendor) {
  combinedDict.features[i++] = {
    "attributes": {
      "date1": v["Invoice_Date"],
      "cost1": v["Invoice_Total"]
    }
  }
}

//return combinedDict;
// Return dictionary cast as a FeatureSet
return FeatureSet(Text(combinedDict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't think you need the combinedDict at all. All you're doing is copy the rows from vendor verbatim. If you're not planning to actually combine vendor with another FeatureSet, this should be enough:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal("https://www.arcgis.com/")
var vendor = GroupBy(
  FeatureSetByPortalItem(portal,"********************",0,["*"],false),
  ["Invoice_Date"],
  [
    { "name": "Invoice_Total", "expression": "Invoice_Total", "statistic": "SUM" }
  ]
)
return vendor&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 10:05:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123727#M5450</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-12-08T10:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Chart With Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123777#M5451</link>
      <description>&lt;P&gt;Good catch! FWIW, you can totally omit quotes on the dict keys and Arcade has no problem with it.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 13:33:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123777#M5451</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-12-08T13:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Chart With Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123786#M5452</link>
      <description>&lt;P&gt;Ah OK, thanks for the tip. I was wondering why that wouldn't throw an error. Seems to be a Javascript concept.&lt;/P&gt;&lt;P&gt;I don't know how to feel about this, seems kinda dirty to me. Although I really like the reverse, where you just call &lt;STRONG&gt;dict.key&lt;/STRONG&gt; instead of the pythonic &lt;STRONG&gt;dict["key"]&lt;/STRONG&gt;. Seems like Arcade handles dictionaries like duck typed objects in Python.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 14:01:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123786#M5452</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-12-08T14:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Chart With Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123887#M5454</link>
      <description>&lt;P&gt;I really appreciate the help! That did get rid of the error for me but unfortunately my expression doesn't give me a running sum total like i thought it was going to.&amp;nbsp; &amp;nbsp;I don't have much experience writing these types of expressions so its a bit of searching around trying this and that.&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 16:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1123887#M5454</guid>
      <dc:creator>JoshHabel</dc:creator>
      <dc:date>2021-12-08T16:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Chart With Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1124203#M5457</link>
      <description>&lt;P&gt;So you want something like this?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal("https://www.arcgis.com/")
var vendor = GroupBy(
  FeatureSetByPortalItem(portal,"********************",0,["*"],false),
  ["Invoice_Date"],
  [
    { "name": "Invoice_Total", "expression": "Invoice_Total", "statistic": "SUM" }
  ]
)

var combinedDict = {
  "fields": [
    { "name": "date1", "type": "esriFieldTypeDate" },
    { "name": "cost1", "type": "esriFieldTypeDouble" },
    { "name": "running_sum1", "type": "esriFieldTypeDouble" },
  ],
  "geometryType": "",
  "features": []
}

var i = 0
var running_sum = 0
for (var v in vendor) {
  running_sum += v["Invoice_Total"]  // increase the running sum
  combinedDict.features[i++] = {
    "attributes": {
      "date1": v["Invoice_Date"],
      "cost1": v["Invoice_Total"],
      "running_sum1": running_sum 
    }
  }
}

//return combinedDict;
// Return dictionary cast as a FeatureSet
return FeatureSet(Text(combinedDict))&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 09 Dec 2021 08:24:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1124203#M5457</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-12-09T08:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Chart With Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1124304#M5460</link>
      <description>&lt;P&gt;Alternate method: &lt;A href="https://github.com/jdcarls2/arcade-expressions/blob/running-total/dashboard_data/RunningTotal(SerialChart).md" target="_blank"&gt;https://github.com/jdcarls2/arcade-expressions/blob/running-total/dashboard_data/RunningTotal(SerialChart).md&lt;/A&gt; Your post has inspired me to finish this script and submit a PR, so thanks!&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;may have a quicker solution here, though.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 14:02:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1124304#M5460</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-12-09T14:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Chart With Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1124976#M5468</link>
      <description>&lt;P&gt;Johannes,&lt;/P&gt;&lt;P&gt;Tried your expression above and it worked great!&amp;nbsp; See below... Really appreciate the help!!&lt;/P&gt;&lt;P&gt;Have a good holiday!&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JoshHabel_0-1639161030519.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/29426i942E06B9DA0179F2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JoshHabel_0-1639161030519.png" alt="JoshHabel_0-1639161030519.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 18:40:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/cumulative-chart-with-arcade-expression/m-p/1124976#M5468</guid>
      <dc:creator>JoshHabel</dc:creator>
      <dc:date>2021-12-10T18:40:04Z</dc:date>
    </item>
  </channel>
</rss>

