Skip to content

Commit

Permalink
docs - casting to a specific data type (#15503)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-bruemmer committed Apr 6, 2021
1 parent 9b29048 commit 471eda1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion docs/administration-guide/03-metadata-editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ You can add descriptions to tables to let people know the type of data a table c

![Learn about your data in the SQL editor](./images/learn-about-your-data-sql-editor.png)


#### Original schema

If you ever want to see the original underlying schema for a given table, just click the **Show original schema** toggle in the top-right of the screen.
Expand Down Expand Up @@ -161,6 +160,21 @@ You can also designate a column as the table's **primary key** or **foreign key*
- **Other**
- Field containing JSON

### Casting to a specific data type

You can manually cast text and number columns to date fields. Casting is useful if your date/timestamps are stored as text or number fields in your database, but you want Metabase to treat them like date values (so it'll do things like present calendar pickers for filters). Casting is different from changing the field type in Metabase, which only modifies semantic information to give people more context about that field, like setting a date field as a "Cancellation date." By contrast, casting changes the underlying type so that, for example, Metabase will interpret a string field as if it were a date.

You can cast text in ISO8601 format and numbers representing Unix epoch to date, datetime, or time types. The exact casting options will differ depending on which kind of database you're connected to, but here are some types you can cast:

- ISO8601->Date
- ISO8601->Datetime
- ISO8601->Time
- UNIXMicroSeconds->DateTime
- UNIXMilliSeconds->DateTime
- UNIXSeconds->DateTime

To cast a field to a different type, click on the gears icon next to the field you want to cast. If the field is a number or text field, you may see an option to **Cast to a specific data type**, with a default option set to "Don't cast." Select the type you want to cast to, and you're good to go. Casting doesn't affect the original data type; just how Metabase interprets that field.

### Remapping column values

One thing that happens commonly in tables is that you'll have a **foreign key column**, like `Product ID`, with a bunch of ID values in it, when what you actually want to see most of the time is the **entity name**, like the `Product Title`. You might also have fields which contain coded values that you'd prefer to show up as translated or readable values in your tables and charts — like changing `0`, `1`, and `2` to `Female`, `Male`, and `Other`.
Expand Down

0 comments on commit 471eda1

Please sign in to comment.