I have a column called 'name' with trail names that repeat sometimes and a column called 'sec_length_ft' with the length of each trail segment. I want to use GroupBy to add up the sections of the same trail name to populate the 'trail_ft' column. The code I've come up with is below. It runs without errors, but the table doesn't update.
GroupBy(FeatureSetByName($datastore, 'TrailLinesQAQC'),'name',
{name: 'trail_ft', expression: 'sec_length_ft', statistic: 'SUM'})
TrailLinesQAQC is the name of the layer
Trail_ft is the column I want to be updated
name is the names of the trails that I want to group the data by
sec_length_ft is the name of the column that contains values of trail segments to be added up for the trail_ft column
Thanks for your help.
Solved! Go to Solution.
// load the feature set
var fs = FeatureSetByName($datastore, 'TrailLinesQAQC')
// filter for name
var name = $feature.name
var filtered_fs = Filter(fs, "name = @name")
// get sum of sec_length_ft
return Sum(filtered_fs, "sec_length_ft")
This should work, too:
// do it with GroupBy
var group = GroupBy(FeatureSetByName($datastore, 'TrailLinesQAQC'),'name',
{name: 'trail_ft', expression: 'sec_length_ft', statistic: 'SUM'})
// you still have to filter it
var name = $feature.name
var filtered_group = Filter(group, "name = @name")
return First(filtered_group).trail_ft
// load the feature set
var fs = FeatureSetByName($datastore, 'TrailLinesQAQC')
// filter for name
var name = $feature.name
var filtered_fs = Filter(fs, "name = @name")
// get sum of sec_length_ft
return Sum(filtered_fs, "sec_length_ft")
This should work, too:
// do it with GroupBy
var group = GroupBy(FeatureSetByName($datastore, 'TrailLinesQAQC'),'name',
{name: 'trail_ft', expression: 'sec_length_ft', statistic: 'SUM'})
// you still have to filter it
var name = $feature.name
var filtered_group = Filter(group, "name = @name")
return First(filtered_group).trail_ft
Thank you so much Johannes! You saved me so many hours of work!
Glad to have helped. Please accept the answer so that the question is marked as solved.
is there an example of GroupBy for the calculate field in Arc Pro where the layer and field name are already designated ?
i.e what goes in the expression box? thanks