Hello,
First of all I am a beginner to all but the most basic arcade expressions so this is all brand new to me. I want to be able to create cumulative charts that sum a value and allow the data to be parsed by date. The example i'm trying here is to sum all my invoices starting from Jan 1st, 2021 going forward. I've modified the below expression which I got from the above post . Seems like it should work but all i get is a Execution Error: Error. Not very helpful for troubleshooting. Is there something i'm missing??? I feel like its probably with my filter date expression but that just a guess.
Josh
// Get your input layer
var fs = FeatureSetByPortalItem(Portal('***********'), '************', 0, ['Invoice_Date', 'Invoice_Total'], false)
// Filtering input to a single quarter.
var invoices_21 = Filter(fs, "Invoice_Date > '2021-01-01'")
// Grouping by sale date to get per-date total
var invoicing = GroupBy(invoices_21, 'Invoice_Date', {name: 'total', expression: 'Invoice_Total', statistic: 'SUM'})
var fs_dict = {
fields: [
{name:'date', type:'esriFieldTypeDate'},
{name:'running_sum', type:'esriFieldTypeDouble'}],
geometryType: '',
features: []
}
var i = 0
for(var s in invoicing){
// Get all dates before or equal to date
var filt_date = s['Invoice_Date']
var running_sum_fs = Filter(invoicing, "Invoice_Date <= @filt_date")
// Populate dict
fs_dict.features[i] = {
attributes: {
'date': filt_date,
'running_sum': Sum(running_sum_fs, 'total')
}
}
console(filt_date)
console(sum(running_sum_fs, 'Invoice_Total'))
i ++
}
return featureset(text(fs_dict))