Select to view content in your preferred language

Arcade Date Filter() using Between giving error

456
1
Jump to solution
02-10-2023 01:43 PM
Labels (1)
ZachPorteous
New Contributor III

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....

ZachPorteous_0-1676065246713.png

 

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'])

 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

$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


Have a great day!
Johannes

View solution in original post

0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor

$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


Have a great day!
Johannes
0 Kudos