parameter

LookML
Version

On this Page
Docs Menu

Go to Field Parameter List

Definition

There is a LookML parameter that is actually called “parameter”. The parameter parameter creates a filter-only field; a user can add a parameter as a filter when exploring, but they cannot add them to their result set. The values that a user puts into this filter-only field are then made useful via the {% parameter %} liquid variable.

The parameter name must:

  • be unique within any given view
  • consist of characters a through z (no capital letters), 0 through 9, or _
  • start with a letter

There are many types of parameter types, as discussed further here.

Specifying Allowed Values

If you need to set the specific values that a user may choose for a parameter, you can do so by using allowed_values. Allowed values specify pairs of labels and values. The label is what the user will see in the filter options, and the value contains the value you want to insert into the {% parameter %} liquid variable.

For example, this would produce a parameter that gives a user 3 options:

- parameter: number_of_results type: string allowed_values: - value: '< 500' label: 'Less than 500' - value: '< 10000' label: 'Less than 10,000' - value: '> 0' label: 'All Results'

The allowed_values parameter is similar to the suggestions parameter, in that it allows you to set the filter options a user may choose from. However, the allowed_values parameter adds the extra functionality of mapping a user-friendly label with the value you want to use.

Examples

In this example we create a parameter called Item To Add Up that lets a user choose what database column they want to sum. A corresponding measure called Dynamic Sum then makes use of the {% parameter %} liquid variable to perform the calculation:

- parameter: item_to_add_up type: unquoted allowed_values: - value: 'sale_price' label: 'Total Sale Price' - value: 'cost' label: 'Total Cost' - value: 'profit' label: 'Total Profit'   - measure: dynamic_sum type: sum sql: ${TABLE}.{% parameter item_to_add_up %} value_format_name: 'usd'

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