decimals

LookML
Version

On this Page
Docs Menu

Go to Field Parameter List

Definition

As of release 3.38, use value_format instead of decimals.

You can set the number of decimals to be displayed for fields that contain number type values. For example:

- measure: total_cost type: sum sql: ${cost} decimals: 2

One common SQL quirk that arises when using decimals is the way that SQL handles integer math. If you divide 5 by 2, most people expect the result to be 2.5. However, many SQL dialects will return the result as just 2, because when it divides two integers it also gives the result as an integer. To address this, you can multiply the numerator by a decimal number (like 1.0 or 100.0) to force SQL into returning a decimal result. For example:

- measure: active_users_percent type: number sql: 100.000 * ${active_users} / ${users} decimals: 3

Still have questions?
Go to Discourse - or - Email Support
Top