Most fields in the field picker are created by your Looker developers. By using custom fields, however, you can create new ad hoc custom dimensions and measures in an Explore. This page discusses how to create and use custom fields to enhance your data analysis.
To use custom fields, your Looker admin must:
- Enable the Custom Fields Labs feature.
- Grant the
create_custom_fields
permission to users or groups to allow access to the feature.
When you have access to custom fields, there are several types of custom fields you can create:
- A custom measure based on an existing dimension
- A filtered custom measure based on an existing measure
- A custom dimension based on a Looker expression
Custom fields are different from LookML-defined fields and table calculations
There are a few differences between custom fields and dimensions and measures that are defined in LookML, including:
- There is no drilling capability for custom fields.
- Custom fields only persist in an Explore’s field picker for certain users.
There are a few differences between custom fields and table calculations:
- Custom fields generate SQL that will run against the database, similar to a LookML field.
- Custom fields are not dependent on data from the data table.
Custom field types
You can create and customize several types of custom fields, depending on the base LookML field type or types. The following tables outline the types of custom fields that are available to create based on the LookML field type:
Custom field types for dimensions
You can create several custom field types from dimensions in an Explore’s field picker, depending on the base LookML field type or types. The following table outlines the types of custom fields that are supported for each type of dimension.
s = Works with the string
data type
n = Works with the number
data type and numeric measures
t = Works with the tier
data type
zc = Works with the zipcode
data type
yn = Works with the yesno
data type
di = Works with the distance
data type
du = Works with the duration
data type
ts = Works with most timestamp data types*
id = Works with most integer date data types*
sd = Works with most string date data types*
l = Works with the location
data type
Each custom field type that you can create from a dimension falls into one of the following categories:
- Aggregate — Aggregated fields are measures types that perform aggregations, such as sum and average. Aggregate measures can reference only dimensions, not other measures.
- Non-aggregate — Non-aggregated fields are dimensions that can be grouped by in an Explore query.
Custom field name | Category | Description | LookML field type compatibility |
---|---|---|---|
Count distinctCount distinct |
Aggregate |
Creates a count_distinct measure that calculates the number of distinct values for a selected dimension.
|
s n t zc yn di du ts id sd l |
SumSum |
Aggregate |
Creates a sum measure that adds up the values of a selected dimension.
|
n di du id |
AverageAverage |
Aggregate |
Creates an average measure that averages the values of a selected dimension.
|
n di du id |
MinMin |
Aggregate |
Creates a min measure that finds the smallest value of a selected dimension.
|
n di du ts id |
MaxMax |
Aggregate |
Creates a max measure that finds the largest value of a selected dimension.
|
n di du ts id |
MedianMedian |
Aggregate |
Creates a median measure that finds the midpoint value for the values of a selected dimension.
|
n di du id |
List of unique valuesList of unique values |
Aggregate |
Creates a list measure that creates a list of the distinct values of a selected dimension.
|
s t zc yn sd l |
BinBin |
Non-aggregate | Creates bins, or tiers, that separate the values of a selected numeric dimension into a custom set of number ranges. | n di du id |
GroupGroup |
Non-aggregate | Creates a group that lets you bucket results of a selected dimension under custom labels. | s n t zc yn di du ts id sd l |
* Note about date and time data: Looker interprets some timeframes and time-based types as different data types when you’re creating custom fields, and this can affect the custom field types that are available for those timeframe and time-based fields. For example, Looker interprets the hour_of_day timeframe as a number data type and therefore has custom field options available to other type: number fields. For more specific information, see the How custom fields interpret date and time data types section on this page. |
Custom field types for measures
You can create only one custom field type, a filtered measure, from measures in an Explore’s field picker, depending on the base LookML measure type. The following table outlines the LookML fields to which measure types you can add a filter.
Custom field name | Description | LookML field type compatibility | |
---|---|---|---|
Filter measureFilter measure |
Adds a filter condition to a measure to limit the values included in the measure’s aggregation. | s li dt yn n | |
* For more specific information on the types of measures Looker interprets as numeric while it’s using custom fields, see the How custom fields interpret numeric measures section on this page. |
How custom fields interpret date and time data types
Looker interprets some timeframes and time-based types as different data types when you’re creating custom fields, which affects the type of custom fields that you can create for a given date or time field. Custom fields categorize date and time fields in the following ways:
These categories are compatible with different types of custom fields, as indicated in the Custom field types for dimensions table.
Timestamp date data types
Custom fields treat the following LookML time data types as timestamp data types:
date
time
microsecond
millisecond
millisecondX
second
minute
minuteX
hour
hourX
week
month
quarter
fiscal_quarter
fiscal_year
year
Integer date data types
Custom fields treat the following LookML date and time data types as integer date types:
String date data types
Custom fields treat the following LookML date and time data types as string data types:
How custom fields interpret numeric measures
Custom fields treat the following measure types as numeric types:
average
average_distinct
count
count_distinct
max
median
median_distinct
min
percent_of_previous
percent_of_total
percentile
percentile_distinct
running_total
sum
sum_distinct
These measure types are compatible with the filtered measure custom field type, as indicated in the Custom field types for measures table.
The
type: number
measure type is not compatible with custom fields.
Creating a custom measure from a dimension
You can create a custom measure from a dimension in one of the following ways:
Using the dimension’s three-dot Options menu
Using the Custom Fields section
Using the dimension’s three-dot Options menu
In many cases, you can use this shortcut technique:
- Expand the view that contains the dimension that you want to measure. In this example, you want to create a custom field based on the Cost dimension.
- Select the dimension’s three-dot Options menu.
- Select a function. Select Aggregate to display options for creating a custom measure. The example below uses Average to create a measure that calculates the average of an order item’s cost. The suggested functions vary based on the type of dimension you’ve chosen (such as number, text, and date).
- Expand the Custom Fields section to see your new field.
- As with other fields, you can select a custom field’s name to add or remove it from a query. You can also hover over the field to reveal more options available for that field, including selecting its Filter icon to use it as a filter in a query.
Using the Custom Fields section
If you want to define a format or a filter for your custom measure while creating it, start with the Add button on the Custom Fields section:
- Expand the Custom Fields section.
- Select Add.
- Select the type of field that you want to create. This example uses Custom Measure.
- Select a field to measure, select the measure type from the drop-down options, and then specify a name. The field name appears in the field picker and in the data table.
- If you want to add a filter condition, select a field from the Select a field drop-down on the Filters tab. You can also select the downward-facing arrow next to Custom filter to create a custom filter expression using any Looker functions and operators that can be used in custom filters. The Looker expression editor will suggest field names and display syntax help for any functions you use. Fields that are both currently used in an Explore and eligible to be used with the field type that you’re creating are marked with a black circle. Refer to the Adding a custom filter to a custom measure section on this page for more details about adding filters to measures.
- On the Field details tab, you can specify a format and add an optional description to give other users additional details about the custom field, including its intended use.
- Select Save.
The field picker displays your new custom measure in the Custom Fields section. As with other fields, you can select a custom field’s name to display it in a query. You can also select its Filter button to use it as a filter in a query.
Custom grouping
The Group custom field type lets you create ad hoc custom groups for dimensions and custom dimensions without needing to use logical functions in Looker expressions or needing to develop CASE WHEN
logic in sql
parameters or type: case
fields.
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.
To create a group:
- Expand the view that contains the dimension for which you want to create custom groups. In this example, you want to create custom groups for the State dimension.
- You can perform the next step in two different ways:
- Expand the view, select the dimension’s three-dot Options menu, and then select Group to open the Group By menu.
- If the field is already selected in an Explore, you can select Group from the dimension’s gear menu in the Data table to open the Group By menu, and follow the next steps to create custom groups.
- Specify a label for the first group of values. This example illustrates how to create a group of states for the Pacific Northwest region of the United States.
- Click the default condition, is any value, to customize the conditions that you want to apply for the group.
- Select the condition, and enter or select one or more values. In this case, one of the conditions applied is State is Oregon. Select the plus sign (+) next to the value to add multiple conditions for the selected field, or click outside of the filter condition settings to save.
- When available, value suggestions will appear in a drop-down list, which is indicated with a downward-facing arrow in the value input box, for users to select or search against. Suggestions are most commonly available for fields of
type: string
. - Looker automatically applies SQL conditions such as
AND
orOR
logic when multiple conditions are created, based on the field types, conditions, and values that you specify. - If you’re editing an existing custom group, consider changing the name to reflect the updated conditions.
- When available, value suggestions will appear in a drop-down list, which is indicated with a downward-facing arrow in the value input box, for users to select or search against. Suggestions are most commonly available for fields of
- To add more groups for that dimension, hover over the existing group and select the plus sign (+); to remove groups, select the minus sign (-). You can edit an existing group by selecting the group condition — is Oregon or Idaho or Washington in this case.
- Looker automatically applies SQL conditions such as
AND
orOR
logic when multiple conditions are created, based on the field types, conditions, and values that you specify.
- Looker automatically applies SQL conditions such as
- Optionally, select the Group remaining values checkbox to create a category for grouping all other values that do not satisfy any group conditions. In this example, any state that is not Oregon, Idaho, or Washington would be grouped under a label named Other. Other is the default name, but you can customize it, as desired.
- If you’re editing a custom group and want to remove grouping for all other values, select the Group remaining values checkbox to remove that group.
- Specify a name other than the default as desired. The field name appears in the field picker and in the data table. The default name for custom groups is
Dimension_Name
Groups; in this case, the name is State Groups. - Select + Add Description to add an optional description of up to 255 characters to give other users more information about the custom group.
- If you’re editing a custom group and there is an existing description, the Description box will automatically appear.
- Select Save and then Run to rerun the Explore.
The new field will appear in the data table, and display labels for states depending on whether they are or are not in the Pacific Northwest region:
You can use the new group to make new insights into your data. For example, compare how many orders have been placed by users in the Pacific Northwest region to users living in other regions in the United States:
The new field will appear in the Custom Fields section of the field picker. As with other fields, you can select the field’s name to add or remove it from a query. You can also hover over the field to reveal more options available for that field, including selecting its Filter icon to use it as a filter in a query.
Custom binning
The Bin custom field type lets you create ad hoc custom bins, or tiers, for numeric type dimensions and custom dimensions without needing to use logical functions in Looker expressions or needing to develop type: tier
LookML fields.
This can be helpful when you want to quickly group values into specific integer ranges to adjust the granularity of your data.
Bin custom fields appear in the classic
tier notation style.
To create a bin:
- Expand the view that contains the dimension for which you want to create custom bins. In this example, you want to create custom bins for the Cost dimension.
- You can perform the next step in two different ways:
- Expand the view, select the dimension’s three-dot Options menu, and then select Bin to open the Bin menu.
- If the field is already selected in an Explore, you can select Bin from the dimension’s gear menu in the Data table to open the Bin menu, and follow the next steps to create custom bins.
- As an optional starting point, select Get field info to learn more about the values for the dimension for which you’re creating custom bins, including the dimension’s minimum value, its maximum value, and its range of values. Having this information can be helpful in determining the way in which you specify value bins.
- Select 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.
- Customize the bin sizes and ranges.
- If the selected Bin type is Equal-sized, enter the desired Bin size, Minimum value, and Maximum value. The preceding example displays specifications of bins of 10, ranging from 0 to 100. Bins are automatically created for values in the data that fall outside the specified ranges.
- If the selected Bin type is Custom-sized, specify the tier breakpoints in ascending order in the Bin breakpoints field, separated either by commas or new lines.
Starting in Looker version 22.6, a maximum of 500 total bins can be created for each Bin custom field type.
- Specify a name other than the default as desired. The field name appears in the field picker and in the data table. The default name for custom bins is
Dimension_Name
Bins; in this case, the name is Cost Bins. - Select + Add Description to add an optional description of up to 255 characters to give other users more information about the custom bin.
- If you’re editing a custom bin that has an existing description, the Description box automatically appears.
- Select Save and then Run to rerun the Explore.
The new field will appear in the data table, and it displays tier levels for values depending on where they fit into specified bins:
You can use the new bin to make new insights into your data. For example, you can compare the number of orders that contain items priced in specific cost ranges:
The new field will appear in the Custom Fields section of the field picker. As with other fields, you can select the field’s name to add or remove it from a query. You can also hover over the field to reveal more options that are available for that field — for example, you can select the field’s Filter icon to use it as a filter in a query.
Adding a filter to a custom measure
Applying filters to custom measures allows a measure to limit the data, such as only including orders from certain regions. You can add a custom filter to a custom measure when you’re creating or editing a custom measure. To add a filter to a custom measure:
- In the field picker, expand the Custom Fields section.
- Select Add and select Custom Measure to create a new custom measure, or select an existing custom measure’s three-dot Options menu to edit an existing custom measure.
- If you’re editing a field, select Edit.
- Select the field that you want to filter by from the Select a field drop-down. In this example, the user chooses to filter by Cost.
- Click is any value to customize the filter conditions that you want to apply.
- Select the condition, and enter or select a value. In this case, the condition applied is Cost is > 100. Select the plus sign (+) next to the value to add multiple conditions for the selected field, or click outside of the filter condition settings to save.
- When available, value suggestions will appear in a drop-down list, which is indicated with a downward-facing arrow in the value input box, for users to select or search against. Suggestions are most commonly available for fields of
type: string
. - If you’re editing an existing custom measure, consider changing the custom measure’s name to reflect the filter condition. The field name appears in the field picker and in the data table. In this example, the field name was changed from Average of Order Item Cost to Average Cost of Order Items over $100.
- When available, value suggestions will appear in a drop-down list, which is indicated with a downward-facing arrow in the value input box, for users to select or search against. Suggestions are most commonly available for fields of
- To add more filters, hover over the existing filter and select the plus sign (+); to remove filters, select the minus sign (-).
- Looker automatically applies SQL conditions such as
AND
orOR
logic when you create multiple filters, based on the field types, conditions, and values that you specify.
- Looker automatically applies SQL conditions such as
- Optionally, click the downward-facing arrow next to Custom filter at the bottom of the Filters tab to expand the Custom filter text box to add a custom filter instead of or in addition to a UI-based filter. Enter a Looker expression in the Custom filter box using any Looker functions and operators that can be used in custom filters. The Looker expression editor will suggest field names and display syntax help for any functions you use. Fields that are both currently used in an Explore and eligible to be used with the field type that you’re creating are marked with a black circle.
- Add any desired formatting and an optional description of up to 255 characters on the Field details tab.
- Select Save.
Creating a filtered measure from another measure
To create a custom measure that copies an existing measure and adds a filter:
- Expand the view that contains the measure to which you want to add a custom filter. The measure cannot be a custom measure or a
type: number
measure. To add a filter expression to an existing custom measure, you will need to edit the custom measure. In this example, a filter expression is added to the Count measure. - Select that measure’s three-dot Options menu.
- Select Create filtered measure.
- Specify the name. The field name appears in the field picker and in the data table. In the Filters section, select the field that you want to filter by from the Select a field drop-down. In this example, the user chooses to filter by Category.
- Click is any value to customize the filter conditions that you want to apply.
- Select the condition, and enter or select a value. In this case, the condition applied is Category is Accessories. Select the plus sign (+) next to the value to add multiple conditions for the selected field, or click outside of the filter condition settings to save.
- When available, value suggestions will appear in a drop-down list, which is indicated with a downward-facing arrow in the value input box, for users to select or search against. Suggestions are most commonly available for fields of
type: string
. - If you’re editing an existing custom measure, consider changing the custom measure’s name to reflect the filter condition. In this example, the field name was changed from the default Filtered Inventory Items - Count to Accessories Inventory Count.
- When available, value suggestions will appear in a drop-down list, which is indicated with a downward-facing arrow in the value input box, for users to select or search against. Suggestions are most commonly available for fields of
- To add more filters, hover over the existing filter and select the plus sign (+); to remove filters, select the minus sign (-).
- Looker automatically applies SQL conditions such as
AND
orOR
logic when you create multiple filters, based on the field types, conditions, and values that you specify.
- Looker automatically applies SQL conditions such as
- Optionally, click the downward-facing arrow next to Custom filter at the bottom of the Filters tab to expand the Custom filter text box to add a custom filter instead of or in addition to a UI-based filter. Enter a Looker expression in the Custom filter box using any Looker functions and operators that can be used in custom filters. The Looker expression editor will suggest field names and display syntax help for any functions you use. Fields that are both currently used in an Explore and eligible to be used with the field type that you’re creating are marked with a black circle.
- Add any desired formatting and an optional description of up to 255 characters on the Field details tab.
- Select Save.
The field picker displays the new measure in the Custom Fields section:
As with other measures, you can select a custom measure’s name to add or remove it from a query. You can also hover over the field to reveal more options available for that field, including selecting its Filter icon to use it as a filter in a query.
Creating a custom dimension using a Looker expression
To create a custom dimension using a Looker expression and one or more other dimensions:
- Expand the Custom Fields section.
- Select Add.
- Choose Custom Dimension.
- Specify the name and format that you want to use. The field name appears in the field picker and in the data table. In the Expression box, enter aLooker expression that calculates the value for your dimension, using any Looker functions and operators. The Looker expression editor will suggest field names and display syntax help for any functions you use. Fields that are currently used in an Explore and that are eligible to be used with the field that you’re creating are marked with a black circle.
- Select + Add Description to add an optional description of up to 255 characters to give other users more context or information about the custom dimension.
- Select Save.
The field picker displays your new custom dimension in the Custom Fields section:
As with other fields, you can select a custom dimension’s name to add or remove it from a query. You can also hover over the field to reveal more options available for that field, including selecting its Filter icon to use it as a filter in a query.
Viewing and using custom fields
The ability to see custom fields, and how you can interact with them, will be different depending on whether you’re allowed to create them or not.
Viewing custom fields
If you’re allowed to create custom fields, then you can see and edit any that appear in the Custom Fields section of the field picker.
If you’re not allowed to create custom fields, then the Custom Fields section is not displayed in the field picker.
However, if you include a custom field in an Explore, a Look, or a dashboard tile, any users with whom you then share that content can see the custom field regardless of whether they have the ability to create custom fields. If you’re sharing this content by sharing an Explore’s URL, the URL must include the qid
parameter (such as instance_name.looker.com/explore/ec/order_items?qid=lEPPueGN7cHkozOEZVDQbO
). Users who aren’t allowed to create custom fields will see only the field’s title, not its description, so it’s important to name fields precisely if you’ll be using them in queries shared with these users.
Using custom fields
If you’re allowed to create custom fields, then you can edit and use any that appear in the Custom Fields section of the field picker. You can interact with them almost exactly as you would with any other measures or dimensions, including filtering on them, adding them to visualizations, and (for custom dimensions) using them to pivot results. One exception is that you cannot use custom fields to create dashboard filters.
Only users who are allowed to create custom fields can add them to queries in Explores, Looks, or dashboard tiles. However, if a user selects Explore from here on a shared Look or dashboard tile that includes a custom field, they can create a new query using that field whether or not they have the ability to create custom fields.
Duplicating a custom field
If you’re allowed to create custom fields, you can also duplicate existing custom fields. Duplicating and then editing custom fields can be helpful if you’d like to create multiple custom fields with only small differences (for example, 30-day, 60-day, or 90-day sums).
To duplicate a custom field:
- In the field picker, expand the Custom Fields section.
- Select the three-dot Options menu for the custom field that you want to duplicate.
- Select Duplicate.
The duplicated field appears under the original, using the name of the original field plus the word “Copy” appended to the end.
Next, you can edit the duplicated field, as described next.
Editing a custom field
If you’re allowed to create custom fields, you also can edit custom fields that you or other users have created.
Editing a custom dimension
To edit a custom dimension:
- In the field picker, expand the Custom Fields section.
- Select the three-dot Options menu for the custom field that you want to edit.
- Select Edit.
- Change the custom dimension definition.
- Select a new format from the Format drop-down if desired.
- Enter a new field name as desired. The field name appears in the field picker and in the data table. If you have changed anything on a custom field, consider modifying the name to match.
- Add or update an optional field description of up to 255 characters, to help communicate to users details about the custom dimension, or its intended use.
- If there is an existing description, the Description box will automatically appear. If there is no existing description, select + Add Description to add an optional description.
- Select Save.
Editing a custom measure
To edit a custom measure:
- In the field picker, expand the Custom Fields section.
- Select the three-dot Options menu for the custom field that you want to edit.
- Select Edit.
- To change the field that should be measured, select a new field from the Field to measure drop-down.
- To change the type of measure function, select a new measure type from the Measure type drop-down.
- Enter a new field name as desired. The field name appears in the field picker and in the data table. If the field or measure type were changed, the custom measure’s name should typically be changed to match. For example, if the field Sale Price is changed to Cost, the custom field’s name should also be changed, in this case from Sum of Sale Price to Sum of Cost.
- Add, change, or remove a UI-based or custom filter in the Filter expression box on the Filters tab.
- If there is an existing custom filter, the Custom filter box will automatically appear. If there is no existing custom filter, click the downward arrow next to Custom filter to add an optional custom filter instead of or in addition to a UI-based filter.
- Add, change, or remove any formatting or field description of up to 255 characters by selecting the Field details tab.
- Select Save.
Deleting a custom field
If you’re allowed to create custom fields, you can also delete custom fields you or other users have created. When you delete a custom field, it disappears from the Explore but not from any Looks or dashboard tiles that use that field. Additionally, anyone using a URL for an Explore that had the custom field will still have the field.
To delete a custom field from the field picker:
- In the field picker, expand the Custom Fields section.
- Select the three-dot Options menu for the custom field that you want to delete.
- Select Delete.
You can also use the keyboard shortcuts Command-K (Mac) or Ctrl+K (Windows) to delete custom fields.
You can reinstate a custom field that you’ve deleted by clicking the back arrow on your browser.