Aggregate Functions for Field Types

AVAILABLE API VERSION
API v58.0 and later

Aggregate functions are supported for primitive data types and field types, in addition to an extended set of field types for object fields.

The following tables show how GraphQL field types relate to the aggregate functions. Although format and label can be queried as part of aggregation, they cannot be used for aggregation and are excluded from the tables.

This table lists primitive data type support, such as for Int and String.

avgcountcountDistinctgroupingmaxminsum
Int
String
Boolean
Id
Double
Long

Date and Time field types support a combination of the functions in the previous section in addition to date and time-specific functions. The rows and columns have been switched around for readability.

grouping can't be used with DateTime or Time although it's supported within rollup and cube types when used within a Date or Time function.

DateDateTimeTime
calendarMonth
calendarQuarter
calendarYear
count
countDistinct
dayInMonth
dayInWeek
dayInYear
dayOnly
fiscalMonth
fiscalQuarter
fiscalYear
grouping
hourInDay
max
min
weekInMonth
weekInYear

See the GroupByFunction Type.

The following table lists additional field type support, such as for Currency and Email field types.

avgcountcountDistinctgroupingmaxminsum
Currency
Email
Latitude
Longitude
Percent
PhoneNumber
Picklist
TextArea
Url

Consider these guidelines when working with aggregate functions.

  • label is supported for Picklist and String field types but it's not available with aggregation.
  • format is supported for the following types but it's not available with aggregation.
    • Int
    • Long
    • Double
    • Date
    • DateTime
    • Time
    • Currency
    • Percent
  • Fields of the following types cannot be grouped and don't support aggregation.
    • LongTextArea
    • RichTextArea
    • EncryptedString
    • MultiPicklist
    • Base64
    • JSON
  • Converting date or time fields to a user's time zone isn't currently supported.
  • Converting currency fields to a user's currency isn't currently supported.