Arcade GroupBy() examples in the docs: Show what the resulting SQL looks like

03-17-2022 08:30 PM
Status: Open
Labels (1)
Frequent Contributor II

The Arcade docs have examples for the GroupBy() function:

Returns the count and the average height of each tree type

var treeStats = GroupBy($layer,
  [  // fields/expressions to group statistics by
    { name: 'Type', expression: 'TreeType'},
    { name: 'Status', expression: 'TreeStatus'}
  [  // statistics to return for each unique category
    { name: 'Total', expression: '1', statistic: 'COUNT' }, 
    { name: 'AvgHeight', expression: 'Height', statistic: 'AVG' }, 
    { name: 'MaxPercentCoverage', expression: 'CoverageRatio * 100', statistic: 'MAX' }
// treeStats contains features with columns Type, Status, Total, AvgHeight, MaxPercentCoverage
// Each unique tree type (combination of type and status) will have a count, average height, and maximum value of percent coverage

That GroupBy() stuff can get messy in a hurry. It would help if we could see what the SQL would look like, right in the docs.
(possibly as a comment in the Arcade code example)


Tags (1)