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

823
1
03-17-2022 08:30 PM
Status: Open
Labels (1)
Bud
by
Notable Contributor


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)
1 Comment
Bud
by

As a workaround, I suppose we could implement the sample code and then look at the Logs tab in the Diagnostic Monitor in ArcGIS Pro (in the Help tab in the ribbon). One of the End Cursor log entries might show the SQL query that’s sent to the database. Untested.