Hello, Im trying to use Filter to summarize the next hours worth of data but getting an error for formatting, does anyone know why that would be? the error does not happen in the sandbox....
function reducer(previousVal, val){
return previousVal + val;
}
function calc1hrSumForManyFields(intervals, fieldsArray) {
var fromTime = $feature.datetime;
//var fromTime = Text(fromTime)
var toTime = DateAdd($feature.datetime, 3540000) // 59 minutes in milliseconds
//var toTime = Text(toTime)
var sumIntervals = Filter(intervals, 'datetime between @fromTime and @toTime')
var sumArray = [];
for (var field in fieldsArray) {
Push(sumArray, Sum(sumIntervals,field))
}
return Reduce(sumArray,reducer)
}
var allIntervals = FeatureSetByName($datastore, "Interval_20230201",['*'], false);
var id = $feature.count_id;
var targetIntervals = Filter(allIntervals, `count_id = ${id}`);
return calc1hrSumForManyFields(targetIntervals, ['en_inner_volume','ws_inner_volume'])
Solved! Go to Solution.
$feature.count_id seems to be a text field, but you're missing the quotes in the query.
In line 20, either add the single quotes around {id} or use the @ notation like you did in line 10
$feature.count_id seems to be a text field, but you're missing the quotes in the query.
In line 20, either add the single quotes around {id} or use the @ notation like you did in line 10