Select fields dynamically from a filter to use in a dashboard visual

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?

0 5 118
5 REPLIES 5

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

JVFrancis_0-1714602861909.png

I am able to select only one dimension at a time.
Can you please help?

Ooh, good point. A parameter can only take one value.

I tried using a LookML filter field instead, since those can take any number of values, but those can't be referenced in the sql parameter like we need.

What about defining the permutations that your users are likely to choose?

parameter: manage_columns_filter {
  type: string
  default_value: "DateOfBirth"
  suggestions: [ "DateOfBirth", "DateOfBirth and Age", "DateOfBirth and Salary", "Age", "Age and Salary", "Salary", "DateOfBirth and Age and Salary"]
}

 

sam8_0-1714604945362.png

 

There is no multi selection feature for parameters. You can only select one field at a time.
The multi-selection can be enabled by custom application development using SDK or 
You can just group related dimension and measure in different parameters, 
For example: 
For Dimensions of type Address, you can create a parameter that has city, zip-code, territory etc.
For Dimension of type Personal Details, you can create another parameter having id, name etc.
For Measure of type Aggregate, you can include Avg, sum, count etc.
For Measure of type Currency, you can add related columns in this parameter.
To access these different parameters, you can create respective dynamic measures and dimension so you can select almost multiple dimension and measures at a time.
This is the approach I followed in Ad hoc Report Development.

Thanks @sam8 & @salehaxsid Unfortunately bucketing/grouping won't work for my case as the user would want to select the dimensions or measures in random.Thanks for the help!

Top Labels in this Space
Top Solution Authors