Knowledge Drop

How can I have a 'label' field and a 'value' field for suggestions?

  • 7 July 2021
  • 0 replies
  • 10 views

Userlevel 4

Last tested: Jun 1, 2020
 

This is a feature request: For suggest filters, have a 'label' field and a 'value' field.

There is a workaround using sql_always_where and liquid. The example is for Redshift, you should adapt the code below for your use case.

explore: accidents {

...

sql_always_where: 1=1

{% if accidents.accident_lookup._is_filtered %}

AND accidents.id = CAST(

RTRIM(SPLIT_PART({% parameter accidents.accident_lookup %}, ' <id ', 2),'>')

as int)

{% endif %} ;;

}


view: accidents {

sql_table_name: faa.accidents ;;

dimension: accident_lookup_dim {

hidden: yes

sql: ${accident_number} || ' <id ' || ${id} || '>' ;;

}

parameter: accident_lookup {

suggest_dimension: accident_lookup_dim

}

...

}

 

There are limitations with the above workaround. The underlying value still shows up in the filter textbox after you select it, and it only works well for "single value" filters.

 

This content is subject to limited support.                

 

 

 


0 replies

Be the first to reply!

Reply