Filter on a Text box input list with wildcards

Variables

What if you want to have a Text Input variable on your dashboard where you can enter a list of different search terms to filter your chart?

A few tweaks will be needed to your chart to set this up as lists can only include exact matches and wild cards are not compatible with “is one of” filters. Additionally, the “like” and “equals” options allow for only one value. You will then need to edit the SQL directly in SQL Mode to accommodate this type of filtering in SQL Mode.

customizing filters

To do this, open the Chart Editor using the Edit Chart Data option from the chart menu on your dashboard. Then switch your chart over to SQL Mode and edit the WHERE statement. You will need to insert the following to the statement:

"_Users_"."_Email_" iLIKE any (array[{_TEXT_INPUT_}])

Simply replace Users with your table name, Email with your column name, and TEXT_INPUT with the name of your Text Input variable. Once completed, you can hit Run Query at the bottom of the SQL editor to make sure the syntax is correct. If everything runs without error, click Save Chart to save the changes.

The last step will be to customize your Text Input variable. In order to search the entire string in the email column, you will need to use wildcards (%). In the Text Input fields on your dashboard, you will need to surround each search term you’d like to use as filters with percent signs like in the example below.

%searchterm%

customizing text input variable

You can keep adding more search terms by clicking on Add value under the current options in the Text Input and clicking on Update once completed. This will update the Text Input variable and filter your chart with the selected values.


Related Variables Help Articles

See more