Label from conditional liquid parameter


(Charlotte Lewis) #1

I have multiple tables that hold the same data source, aggregated with different breakdowns. Instead of building different Explores for each table, I want to provide a parameter for users to select their preferred breakdown and have the data returned reflect this choice. I have a table with columns breakdown_1, breakdown_2 and a bunch of aggregated columns.

If someone selects “Platform and Placement” from breakdown_selected below, the label of breakdown_1 should read “Platform”. Likewise, if someone selects “Age and Gender” from breakdown_selected below, the label of breakdown_1 should read “Age”.

I have tried multiple ways of inserting the liquid into the label of breakdown_1 and nothing is working. “Other” appears in this example.

Is it possible to achieve this?

    parameter: breakdown_selected {
      label: "What dimensions do you want to break the data down by?"
      allowed_value: {
        label: "Platform and Placement"
        value: "platform_placement"
      allowed_value: {
        label: "Age and Gender"
        value: "age_gender"

    dimension: breakdown_1 {
      sql: ${TABLE}.breakdown_1 ;;
        "{% if breakdown_selected._parameter_value == 'platform_placement' %} Platform
         {% elsif breakdown_selected._parameter_value == 'age_gender' %} Age
         {% else %} Other {% endif %}"

(Andrew Powell) #2


To get the label set by a parameter, add this to your dimension definition:

label_from_parameter: parameter_name

See this example from the docs

Hope this helps,