I'm trying to get GroupBy() to calculate the total length of features in the group.
In MS SQL, I can get it like this:
SELECT
MAX(OBJECTID) AS "OID",
COUNT(1) AS "PartCount",
SUM(Shape.STLength()) AS "TotalLength"
FROM mytable
GROUP BY myfield
If I try to do this in Arcade, it fails (complains about the parantheses):
//var fs = FeaturesetByPortalItem(...)
return GroupBy(fs, ["myfield"], [
{name: "PartCount", expression: "1", statistic: "COUNT"},
{name: "TotalLength", expression: "Shape.STLength()", statistic: "SUM"},
])
If I try to sum Shape__Length, it returns an empty Featureset. If I do the sum over the whole fs it works, I guess it just takes too long with the filtering.
Is there a way to get a sum of the shape lengths in each group without doing it manually (and without having a dedicated field in the fs)?
Have a great day!
Johannes