The Group calculated field type lets you create ad hoc custom groups for dimensions without needing to develop CASE WHEN
expressions in calculated fields or logic in SQL.
This can be helpful when you want to assign fixed labels or category names to values that match specific conditions, for example, by grouping specific states or countries into regions or order costs into categories.
This page provides an overview of how to:
- Create a custom group in your data source
- Edit a custom group in your data source
- Create a chart-specific custom group
- Edit a chart-specific custom group
- Reuse a chart-specific custom group
- Related resources
For more information related to custom groups, see the Related resources section on this page and the Create a custom group example on the About calculated fields page.
Create a custom group in your data source
Custom groups that are created in data sources are available in any report that uses that data source. To create a custom group in a data source, follow these steps:
- Edit the data source.
- Click ADD A FIELD.
- Select Add group.
- Select an existing field to group by from the Selected field to group by drop-down menu.
- Specify a name in the New field name field.
- This is the default name that appears in your reports. You can change this for individual charts by editing the name in the dimension picker.
- The field name must be unique.
- You can't use a reserved keyword as the field name.
- Edit the default ID provided in the New field ID field, as desired. This ID is used by Looker Studio to identify a field as an alternative to the field name.
- Define the criteria for each group.
- Specify a label for the first group of values in the Group Name field.
- Select Include or Exclude from the Include or Exclude drop-down menu. This specifies whether the group will include or exclude the condition criteria that you create in the next step.
- Select a condition from the Condition drop-down menu.
-
Specify the values for the condition in the Group values field.
If you select the
IN
function, press the Enter key (PC) or Return key (Mac) to input each value. -
To add more groups for that dimension, click the Add group button, and repeat the previous steps to set the group condition.
- Optionally, click the Group remaining values as a new group checkbox to create a category for grouping all other values that do not satisfy any group conditions.
- Specify a label in the Group name for remaining values field.
- Click Save.
Create a custom bin in your data source from a report
Alternatively, you can create a custom group in your data source from a report:
- Create or edit your report.
- Click Add a field in the Data panel.
- Select Add group.
- Select an existing field to group by from the Selected field to group by drop-down menu.
- Specify a name in the New field name field.
- This is the default name that appears in your reports. You can change this for individual charts by editing the name in the dimension picker.
- The field name must be unique.
- You can't use a reserved keyword as the field name.
- Edit the default ID provided in the New field ID field, as desired. This ID is used by Looker Studio to identify a field as an alternative to the field name.
- Define the criteria for each group.
- Specify a label for the first group of values in the Group Name field.
- Select Include or Exclude from the Include or Exclude drop-down menu. This specifies whether the group will include or exclude the condition criteria that you create in the next step.
- Select a condition from the Condition drop-down menu.
-
Specify the values for the condition in the Group values field.
If you select the
IN
function, press the Enter key (PC) or Return key (Mac) to input each value. -
To add more groups for that dimension, click the Add group button, and repeat the previous steps to set the group condition.
- Optionally, click the Group remaining values as a new group checkbox to create a category for grouping all other values that do not satisfy any group conditions.
- Specify a label in the Group name for remaining values field.
- Click Save.
See the Create a custom group example on the About calculated fields page.
Edit a custom group in your data source
Custom groups and calculated fields appear in the data source with an fx symbol. To edit the formula, click fx net to the field name. This opens the formula editor, where you can adjust the field as needed.
Create a chart-specific custom group
Field Editing in Reports must be enabled in the data source.
You must have edit rights to the repot to create and edit calculated fields.
You can't reference other chart-specific calculated fields.
Chart-specific custom groups only exist in the chart in which you create them.
To create a chart-specific custom group:
- Create or edit your report.
- Add a new chart or select an existing chart.
- In the Setup tab of the Properties panel, click + Add dimension
- At the bottom of the field list, click + ADD GROUP.
- Select an existing field to group by from the Selected field to group by drop-down menu.
- Specify a name in the New field name field.
- This is the default name that appears in your reports. You can change this for individual charts by editing the name in the dimension picker.
- The field name must be unique.
- You can't use a reserved keyword as the field name.
- Define the criteria for each group.
- Specify a label for the first group of values in the Group Name field.
- Select Include or Exclude from the Include or Exclude drop-down menu. This specifies whether the group will include or exclude the condition criteria that you create in the next step.
- Select a condition from the Condition drop-down menu.
-
Specify the values for the condition in the Group values field.
If you select the
IN
function, press the Enter key (PC) or Return key (Mac) to input each value. -
To add more groups for that dimension, click the Add group button, and repeat the previous steps to set the group condition.
- Optionally, click the Group remaining values as a new group checkbox to create a category for grouping all other values that do not satisfy any group conditions.
- Specify a label in the Group name for remaining values field.
- Click Save.
Edit a chart-specific custom group
You must have edit rights to the report to create and edit calculated fields.
Chart-specific calculated fields appear in the chart Properties panel on the Setup tab.
When you hover your cursor over the field type next to the field name, an fx symbol will appear. To edit the formula, click fx. This brings up the formula editor, where you can adjust the field as needed.
Reuse a chart-specific custom group
Chart-specific calculated fields only exist in the chart in which you create them. You can't directly reuse chart-specific calculated field, or reference it in other calculated fields.
However, you can copy a chart containing chart-specific calculated fields. The copy will contain any calculated fields defined in the original. You can then edit them as needed in the new chart.