LookML creating a dynamic label from multiple parameters

Hello, I am trying to create a dynamic label for a measure based off multiple parameters.

The end user should be able to select from dynamic_segment_param_1 and parameter: dynamic_segment_param_2, so that if they selected Country and Device Type, the dynamic label for the segment_total_revenue would read as: "Country - Device Total Revenue" essentially like, "dynamic_segment_param_1  + " - " + dynamic_segment_param_2 + " Total Revenue"

The current LookML is set out like:

measure: segment_total_revenue {
hidden: no
type: number
sql: ${segment_total_revenue}  ;;
value_format_name: usd_0
}

 

parameter: dynamic_segment_param_1 {
hidden: no
default_value: "None"
type: unquoted
allowed_value: {
label: "Country"
value: "country"
}
allowed_value: {
label: "Company"
value: "company"
}
allowed_value: {
label: "Device Type"
value: "device_type"
}}

parameter: dynamic_segment_param_2 {
hidden: no
default_value: "None"
type: unquoted
allowed_value: {
label: "Country"
value: "country"
}
allowed_value: {
label: "Company"
value: "company"
}
allowed_value: {
label: "Device Type"
value: "device_type"
}}

Solved Solved
0 2 56
1 ACCEPTED SOLUTION

This LookML should work.

measure: segment_total_revenue {
type: number
sql: ${segment_total_revenue} ;;
value_format_name: usd_0
label: "{% parameter dynamic_segment_param_1 %} - {% parameter dynamic_segment_param_2 %} Total Revenue"
}

Note:
 Liquid variables in Label that return a value based on a filter or require that a query be run before the variable value can be determined won't change the name of the field in the field picker. The field name will only be changed in the resulting visualization.

In this example the field picker and results table will pick up the default values for the parameter fields.

View solution in original post

2 REPLIES 2

This LookML should work.

measure: segment_total_revenue {
type: number
sql: ${segment_total_revenue} ;;
value_format_name: usd_0
label: "{% parameter dynamic_segment_param_1 %} - {% parameter dynamic_segment_param_2 %} Total Revenue"
}

Note:
 Liquid variables in Label that return a value based on a filter or require that a query be run before the variable value can be determined won't change the name of the field in the field picker. The field name will only be changed in the resulting visualization.

In this example the field picker and results table will pick up the default values for the parameter fields.

Thats worked perfect, thank you!

Top Labels in this Space