-
Notifications
You must be signed in to change notification settings - Fork 97
soqlDatatable: Support for Aggregate Queries
James Hou edited this page Jan 24, 2021
·
1 revision
You can make use of valid aggregate queries to create dynamic rollup summaries, particularly when combined with the power of the $recordId bind variable on record flexipages, like showing a quick snapshot of Opportunity values:

soqlDatatable supports the following aggregate query methods:
- avg
- count
- count_distinct
- min
- max
- sum
The only aggregate query operation not supported is the raw count call (without a field API name specified), as this kind of query returns a number instead of AggregateResult SObjects:
--returns an integer
SELECT Count()
FROM User
WHERE Profile.Name = 'Standard User'Invalid SOQL queries will be reported via toast message on the page the soqlDatatable is on.
Considerations
- Aliases do not support spaces or dashes. Use underscores if needed (e.g.
SUM(ExpectedRevenue) Revenue_Sum). -
LIMITclauses are not supported in aggregate queries without aGROUP BYclause. - You can alias column labels the same way that you can in SOQL: either with a space or without a space.
avg(Id)myAvgandavg(Id) myAvgthus are both labeledmyAvgwithin your datatable. - Non-aliased aggregate fields would typically be returned as
expr0,expr1, etc — instead, we swap out theseexprlabels for the aggregate query in question: e.g.avg(Id)is labeledavg(Id)within your datatable. - Date Functions are supported.
Limitations
- Using max/min with any
DateorDateTimefield does not currently display properly.