-
Notifications
You must be signed in to change notification settings - Fork 93
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
). -
LIMIT
clauses are not supported in aggregate queries without aGROUP BY
clause. - You can alias column labels the same way that you can in SOQL: either with a space or without a space.
avg(Id)myAvg
andavg(Id) myAvg
thus are both labeledmyAvg
within your datatable. - Non-aliased aggregate fields would typically be returned as
expr0
,expr1
, etc — instead, we swap out theseexpr
labels 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
Date
orDateTime
field does not currently display properly.