I want to add a feature for the user to select which latency metric they should look at in the dashboard (p50, p75, p90, p95).
For this, I'm creating a parameter which will take the user's input on the metric to look.
parameter: latency_metric {
type: unquoted
allowed_value: {
label: "50th %tile"
value: "50"
}
allowed_value: {
label: "75th %tile"
value: "75"
}
allowed_value: {
label: "90th %tile"
value: "90"
}
allowed_value: {
label: "95th %tile"
value: "95"
}
}
Next, I'm passing the metric chosen in to the measure parameter to compute the selected metric.
measure: custom_latency {
description: "Custom latency"
label_from_parameter: latency_metric
type: percentile
percentile: latency_metric._parameter_value
sql: ${latency} ;;
}
But in the "measure" parameter I'm getting an error "Must provide a number for "percentile"". I'm unsure how can I convert the user input to number type since "parameter" parameter takes only string inputs. Moreover, I'm unsure if this is even supported since in the Liquid I didn't find any reference to using this Liquid syntax with the "percentile" sub-param.
Any suggestions on how I can fix my approach or any other approach that would work?
You might try setting the type of the parameter to 'unquoted' - that will stop Looker dropping the parameter into your SQL as a string.