Create a custom bin

The Bin calculated field type lets you create ad hoc numeric tiers for numeric dimensions without needing to develop CASE WHEN expressions in calculated fields or logic in SQL.

The Bin calculated field type can be helpful when you want to quickly group values into specific integer ranges to adjust the granularity of your data.

This page explains how to create and edit custom bins, and includes the following sections:

Create a custom bin in a reusable data source

You can use custom bins that exist in a reusable data source in any report that includes that data source. To create a custom bin in a data source, follow these steps:

  1. Edit the data source.

  2. Click ADD A FIELD.

  3. Select Add bin.

  4. Configure the bin options. For more information, see Configure a custom bin.

  5. Click Save.

Create a custom bin in a data source while editing a report

Alternatively, you can create a custom bin in either a reusable or an embedded data source by following these steps:

  1. Create or edit your report.

  2. In the Data panel, click Add a field.

  3. Select Add bin.

  4. Configure the bin options. For more information, see Configure a custom bin.

  5. Click Save.

Edit a custom bin in your data source

Custom bins and calculated fields appear in the data source with an fx symbol. To edit the formula, click fx next to the field name to open the formula editor, where you can adjust the field as needed.

On the Edit Connection menu field list, a user selects the fx icon to open the formula editor for the calculated field called My Calculated Field.

Create a chart-specific custom bin

Chart-specific custom bins exist only in the chart in which you create them.

To create a chart-specific custom bin, follow these steps:

  1. Create or edit your report.

  2. Add a new chart or select an existing chart.

  3. In the Setup tab of the Properties panel, click + Add dimension.

  4. At the bottom of the field list, click + ADD BIN.

  5. Configure the bin options. For more information, see Configure a custom bin.

  6. Click Save.

Configure a custom bin

When you create a custom bin, you can configure several options to define how Looker Studio groups the data:

  • Selected field to bin by: Select an existing numeric field to bin by from the Selected field to bin by drop-down menu.
  • Bin field format: Select a format for the bin from the Bin field format drop-down menu. Options include the following:
    • Interval "[x,y)"—This format displays the range that includes x and up to but not including y.
    • Integer "x to y"—You must use this format with discrete integer values (such as age).
    • Relational ">=x and < y"—This format works best with continuous numbers (such as dollars).
  • New field name: Specify a name in the New field name field.
    • This name is the default name that appears in your reports. You can change this name 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.
  • New field ID: If you are creating a custom bin in a data source, you can edit the default ID in the New field ID field, if needed. Looker Studio uses this ID to identify a field as an alternative to the field name.
  • Refresh field info: As an optional starting point, click Refresh field info to learn more about the values for the dimension for which you're creating custom bins, including the dimension's minimum and maximum values. Having this information can be helpful in determining the way in which you specify value bins.
  • Apply automatic values: Click Apply automatic values to automatically populate the Bin size, Minimum value, and Maximum value fields for Equal Sized bins.
  • Bin type: Specify a Bin type:
    • Select Equal Sized to bin numeric values into equal integer ranges. For example, tiers of values ranging from 0-10, 10-20, and 20-30.
    • Select Custom Sized to create custom bin sizes of varying integer ranges. For example, tiers of values ranging from 0-15, 15-75, and 75-100.
  • Bin sizes and ranges: Customize the bin sizes and ranges:

    • If the selected Bin type is Equal Sized, enter values in the Bin size, Minimum value, and Maximum value fields.
    • If the selected Bin type is Custom Sized, specify the tier breakpoints in ascending order in the Bin breakpoints box, separated either by commas or by pressing the Enter key (PC) or Return key (Mac). You can also use the Tab key.
  • Bin remaining values: Configure how Looker Studio displays values outside of the specified minimum and maximum bin values:

    • If you select the Bin remaining values outside the min and max as separate bins checkbox, Looker Studio groups values that are less than the minimum bin value into one bin, and values that are greater than the maximum bin value into another bin. The label for these bins depends on the Bin field format that you select (for example, [-inf, min) and (max, inf]).
    • If you don't select this checkbox, each value outside of the minimum and maximum values appears as its own bin.

Edit a chart-specific custom bin

Chart-specific calculated fields appear in the chart Properties panel on the Setup tab.

When you hold the pointer over the field type next to the field name, an fx symbol will appear. To edit the formula, click fx to bring up the formula editor, where you can adjust the field as needed.

Reuse a chart-specific custom bin

Chart-specific calculated fields exist only in the chart in which you create them. You can't directly reuse a chart-specific calculated field or reference it in other calculated fields.

However, you can copy a chart that contains 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.