title | redirect_from | |
---|---|---|
Field types |
|
While data types indicate to a database how it should interpret the values in a field, field types or semantic types describe the meaning of a field. For example, a column's data type could be type/text
but the semantic type may be Email. Field types are just one example of metadata—information about data—that Admins can change in Metabase.
Field types dictate how Metabase displays its data, as well as the column’s special functionality, if any. By marking columns in a table as Latitude and Longitude, Metabase can use the columns to create pin and heat maps. Similarly, designating a column as a URL allows users to click on the link to visit that URL.
Metabase recognizes the following field types:
- Entity Key. The field in this table that uniquely identifies each row. Could be a product ID, serial number, etc.
- Entity Name. Different from the entity key, the entity name represents what each row in the table is. For example, in a Users table, the User column might be the entity name.
- Foreign Key. The column in this table that (usually) refers to the primary key of another table in order to connect data from different tables that are related. For example, in a Products table, you might have a Customer ID field that points to a Customers table, where Customer ID is the primary key.
- Category
- Comment
- Description
- Title
- City
- Country
- Latitude
- Longitude
- State
- Zip Code
- Cost
- Currency
- Discount
- Gross margin
- Income
- Price
- Percentage
- Quantity
- Score
- Share. The same as percentage, so prefer "Percentage".
- Birthday
- Company
- Owner
- Subscription
- User
If your database stores datetimes as a number or string, you can cast that column to a datetime.
- Cancelation date
- Cancelation time
- Cancelation timestamp
- Creation date
- Creation time
- Creation timestamp
- Deletion date
- Deletion time
- Deletion timestamp
- Updated date
- Updated time
- Updated timestamp
- Join date
- Join time
- Join timestamp
- UNIX Timestamp (Milliseconds)
- UNIX Timestamp (Seconds)
- Enum - An abbreviation for “enumerated type,” the value of an enum draws on a predefined list of options. An example of an enum would be a field for the months of the year. This list of twelve options is defined in makeup of the column, and no options outside this list would be valid.
- Product
- Source. For example, the source of a visitor to your website.
- Avatar Image URL
- Image URL
- URL
- Field containing JSON.
- No semantic type – Used for fields that don't fall into any of the above field types.
You can set field types for models, which helps Metabase understand how to work with data in models built using SQL. If you set each column type in a SQL model, people will be able to explore that model using the query builder and drill-through menus.
With records that include integer entity keys, you can also configure text fields in models to surface individual records in search.
When you X-ray a table, model, or entity, Metabase considers both the data type and field type to display different charts that summarize that data.
Knowing what field types are and how they work is helpful when using field filters, as you can only create field filters for certain field types.
If you're an administrator, you can edit field types using the Table Metadata page in the Admin Panel.
While data types themselves can't be edited in Metabase, admins can manually cast data types to be read differently, like interpreting a numerical data type as a date format.
See Working with JSON.