Why do I need to specify a type: for my dimension?

Knowledge Drop

Last tested: Jun 1, 2020
 

The type: of a dimension impacts two things:
1. The filter dropdown options list
2. How the values are rendered on the front end

For filter options, you'll notice the list of available options for a type: date field differ than those of a type: string -- Looker determines which list to use based on the type: parameter defined for the field.

In terms of how values are rendered, if an underlying column is a string datatype but the type: parameter declares number, all values will appear as NULL in an explore since the JavaScript expects a number, as told to it by the type: parameter, but the values themselves are actually strings not numbers so NULLs are returned.
The type: parameter does not do any casting. This is a common point of confusion for customers.

If you don't specify a type: parameter, the type will default to string

This content is subject to limited support.                

Version history
Last update:
‎05-07-2021 09:04 AM
Updated by: