---
schema_version: "1"
id: 68da21dfc34c8718fda49b546dfd555f20773587137617d3240a05d0c4a3c0d3
title: Aggregate Functions for Field Types
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/graphql-api/graphql/guides/aggregate/aggregate-support.md
canonical_url: https://developer.salesforce.com/docs/platform/graphql/guide/aggregate-support.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 6d760e85613a36d389d6819bd0c34b51a5e475e9b2415c6a47fc2e5a296287fc
products:
  - GraphQL API
---
# 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.

## Primitive Data Type Support

This table lists primitive data type support, such as for Int and String.

|         | avg | count | countDistinct | grouping | max | min | sum |
| ------- | :-: | :---: | :-----------: | :------: | :-: | :-: | :-: |
| Int     | ✅  |  ✅   |      ✅       |    ✅    | ✅  | ✅  | ✅  |
| String  |     |  ✅   |      ✅       |    ✅    | ✅  | ✅  |     |
| Boolean |     |       |               |    ✅    |     |     |     |
| Id      |     |  ✅   |      ✅       |    ✅    | ✅  | ✅  |     |
| Double  | ✅  |  ✅   |      ✅       |          | ✅  | ✅  | ✅  |
| Long    | ✅  |  ✅   |      ✅       |    ✅    | ✅  | ✅  | ✅  |

## Date and Time Support

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.

|                 | Date | DateTime | Time |
| :-------------: | :--: | :------: | :--: |
|  calendarMonth  |  ✅  |    ✅    |      |
| calendarQuarter |  ✅  |    ✅    |      |
|  calendarYear   |  ✅  |    ✅    |      |
|      count      |  ✅  |    ✅    |      |
|  countDistinct  |  ✅  |    ✅    |      |
|   dayInMonth    |  ✅  |    ✅    |      |
|    dayInWeek    |  ✅  |    ✅    |      |
|    dayInYear    |  ✅  |    ✅    |      |
|     dayOnly     |      |    ✅    |      |
|   fiscalMonth   |  ✅  |    ✅    |      |
|  fiscalQuarter  |  ✅  |    ✅    |      |
|   fiscalYear    |  ✅  |    ✅    |      |
|    grouping     |  ✅  |          |      |
|    hourInDay    |      |    ✅    |  ✅  |
|       max       |  ✅  |    ✅    |      |
|       min       |  ✅  |    ✅    |      |
|   weekInMonth   |  ✅  |    ✅    |      |
|   weekInYear    |  ✅  |    ✅    |      |

See the [GroupByFunction Type](https://developer.salesforce.com/docs/platform/graphql/guide/aggregate-groupby-schema.md#groupbyfunction-type).

## Additional Field Type Support

The following table lists additional field type support, such as for Currency and Email field types.

|             | avg | count | countDistinct | grouping | max | min | sum |
| ----------- | :-: | :---: | :-----------: | :------: | :-: | :-: | :-: |
| Currency    | ✅  |  ✅   |      ✅       |          | ✅  | ✅  | ✅  |
| Email       |     |  ✅   |      ✅       |    ✅    | ✅  | ✅  |     |
| Latitude    | ✅  |  ✅   |      ✅       |          | ✅  | ✅  | ✅  |
| Longitude   | ✅  |  ✅   |      ✅       |          | ✅  | ✅  | ✅  |
| Percent     | ✅  |  ✅   |      ✅       |          | ✅  | ✅  | ✅  |
| PhoneNumber |     |  ✅   |      ✅       |    ✅    | ✅  | ✅  |     |
| Picklist    |     |  ✅   |      ✅       |    ✅    | ✅  | ✅  |     |
| TextArea    |     |  ✅   |      ✅       |    ✅    | ✅  | ✅  |     |
| Url         |     |  ✅   |      ✅       |    ✅    | ✅  | ✅  |     |

## Aggregate Function Considerations

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.
