Groupability breaks down pretty cleanly along type lines, with a few interesting nuances. The underlying SOAP type appears to be the primary determinant, and some formula fields can be used as groupings.
Types are listed below by UI type, with the SOAP type in parentheses. This information was derived from inspection of numerous field describes via Workbench and the Tooling API.
Groupable Field Types
- Checkbox (boolean)
- Phone (string)
- Picklist (string)
- Email (string)
- Text (string)
- Text Area (string)
- URL (string)
- Number (int). Does not include custom fields, only standard Number fields with SOAP type
int
, likeAccount.NumberOfEmployees
. - Lookup (id)
- Master Detail (id)
- Id (id)
- Date (date)
- Direct cross-object references to groupable fields, up to 5 levels from the root object (SOQL limit), as in
SELECT count(Id) FROM Contact GROUP BY Account.Parent.Parent.Parent.Parent.Name
. Both custom and standard references are groupable. - Formulas of type Checkbox and Date, including cross-object formulas across standard and custom relationships.
Non-Groupable Field Types
- Address Compound Fields
- Components of Address compound fields are groupable if their types otherwise allow it.
- Geolocations, both custom and standard, and whether or not defined as having decimal places, including the compound field and components (location/double)
- Long Text (string)
- Rich Text (string)
- Auto Number (string)
- Multi-Select Picklist (string)
- Number (double), including custom Number fields with or without decimal and regardless of scale.
- Percent (double), including custom Percent fields with or without decimal and regardless of scale.
- Currency (double), including custom Currency fields with or without decimal and regardless of scale.
- Roll-Up Summary Fields (double), including
COUNT
rollups. - Encrypted Text Fields (Classic Encryption; string)
- Encrypted fields that use the probabilistic encryption scheme can’t be used with the SOQL and SOSL GROUP BY clauses
- Date/Time (dateTime)
- Time (time)
- Formulas of types other than Checkbox and Date, including the otherwise-groupable String type.