I am trying to add fields (more than one) dynamically from a filter (which has a list of fields defined as a measure/dimension in the LookML) to an existing dashboard visual (table). So when I select a field or more than one field from the filter the selected fields should appear in the dashboard visual. I tried to achieve this using a parameter as a filter and then by creating a dimension based on the parameter to display the results. But by doing this I am only able to add/select just one field from the filter (I don't see the tag list filter type option for the parameter I am using as a filter in the dashboard) and I need to add more than one field (dynamically based on the field(s) selected in the parameter filter)
Below is my LookML code,
parameter: manage_columns_filter {
type: unquoted
default_value: "DateOfBirth"
allowed_value: {
label: "DOB"
value: "DateOfBirth"
}
allowed_value: {
label: "Age"
value: "Age"
}
allowed_value: {
label: "Salary"
value: "Salary"
}
}
dimension: manage_columns {
label_from_parameter: manage_columns_filter
type: string
sql:
{% if manage_columns_filter._parameter_value == "DateOfBirth" %} ${DateOfBirth}
{% elsif manage_columns_filter._parameter_value == "Age" %} ${Age}
{% else %} ${Salary}
{% endif %};;
}
Can someone please help?
I don't think this will be possible. You can't add multiple fields to a query based on one parameter.
One workaround I can think of is concatenating the values together depending on what the user has selected in the parameter. First, you'd need to change the parameter to accept multiple options:
parameter: manage_columns_filter {
type: unquoted
default_value: "DateOfBirth"
suggestions: [ "DateOfBirth","Age","Salary"]
}
Then, you'd need to make the dimension a concatenation:
dimension: manage_columns {
label_from_parameter: manage_columns_filter
type: string
sql: CONCAT( ""
{% if manage_columns_filter._parameter_value contains "DateOfBirth" %} , "Date of Birth: ", ${DateOfBirth}, "; " {% endif %}
{% if manage_columns_filter._parameter_value contains "Age" %} , "Age: ", ${Age}, "; "{% endif %}
{% if manage_columns_filter._parameter_value contains "Salary" %} , "Salary: ", ${Salary}, "; "{% endif %}
);;
}
So in this example, if the user selected "Age,Salary" in the parameter, the dimension would return: "Age: 33; Salary: 900; ".
Thanks @sam8
I am not able to select multiple values from the Manage Columns filter. Please see screenshot below
I am able to select only one dimension at a time.
Can you please help?