Execution Error:Unnexected[sic] Result querying statistics from layer

196
3
12-22-2020 11:03 AM
Labels (1)
ScottRaznoff12
New Contributor

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

 

0 Kudos
3 Replies
DavidPike
MVP Frequent Contributor

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'"
0 Kudos
ScottRaznoff12
New Contributor

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.

0 Kudos
DavidPike
MVP Frequent Contributor

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?

0 Kudos