Greetings,
I am trying to sum all of the features' 'WOCost' fields for a table with a field in common with my popup layer.
if instead of Sum function i run
Cost = First(FltrFtrs).WoCost
it returns a value. When i run sum (as below) it is throwing error:
var addy = 'UNIT 328 ~ KENWORTH 12 YARD DUMP TRUCK'
var WOs = FeatureSetByName($map,"Shop Costs",["WOCOST"], False)
var filterStatement = "WoAddress = '" + addy + "' and Description = \'Vehicles - General Repair\'"
var FltrFtrs = Filter(WOs, filterStatement)
var Cnt = Count(FltrFtrs)
var Cost = 0
if (Cnt > 0){
Cost = Sum(FltrFtrs, 'WoCost')
}else {Cost = 0}
Execution Error:Unnexected Result querying statistics from layer
the filterStatement looks a bit off, I cant see the current order of the quotes being valid syntax. what are the backslashes doing also (that's maybe just me not using Arcade very much if at all)?
#what you have:
"WoAddress = '" + addy + "' and Description = \'Vehicles - General Repair\'"
#my guess:
"WoAddress = " + addy + " and Description = \'Vehicles - General Repair\'"
#or?
"WoAddress = " + addy + " and Description = 'Vehicles - General Repair'"
The backslashes are escape characters to get those single quotes to render as text. i can change the filter statement to something simple or pass the unfiltered feature set and will still return the same result. Also if I return FltrFtrs
i get a feature set result.
Ah of course, that's a handy one I've not seen before.
The rest looks fine to me, unless some calculate statistics operation is required on the data before that method can be used?