LookML Parameter

This example is provided:

parameter: number_of_results {
  type: string
  allowed_value: {
    label: "Less than 500"
    value: "< 500"
  }
  allowed_value: {
    label: "Less than 10,000"
    value: "< 10000"
  }
  allowed_value: {
    label: "All Results"
    value: "> 0"
  }
}

Unfortunately it is not developed further, but does it mean you could do:

sql: ThisColumn {% parameter number_of_results %} # note, only a space and no arithmetic operator

that becomes:

ThisColumn < 500

In other words, is it pure injection of text that can be used in dimensions, derived tables, etc.?

If you want to use it directly in SQL in its literal way then you’d have to change the parameter type to “unquoted”. Otherwise your SQL would look like: column “> 500”

1 Like

“Inserting unquoted values directly into SQL could create the possibility of unwanted SQL actions. To address this, parameter values of type: unquoted are restricted to the characters A through Z and 0 through 9 (no spaces or other special characters).”

Would this cause a problem with the above example?

Ahh I forgot about this gem.. What a waste of feature. It’s not like everybody has access to LookML to change the values of those parameters :confused: Totally not needed restriction..

In this case, you would have to use one of the hacks:

  • create columns related to your business logic and use unqouted parameter to select a boolean field
  • wrap parameter around sql CASE statement that would perform the logic, then parameter can have any values
1 Like