KNOWLEDGE BASE

How to Filter Data By Wildcard Search With Multiple Keywords


Published: 09 Apr 2021
Last Modified Date: 12 Apr 2021

Question

How to create a single wildcard search filter that allows searching by multiple keywords?

Environment

  • Tableau Desktop

Answer

The following steps are demonstrated in the attached workbook. The required calculation fields differ depending on whether the search is an AND or OR search.
AND Search
  1.  Create a parameter named as Search Terms (Comma Separated).
  • Data type: String
  • Current value: keep it blank.
  • Allowable values: All
  1. Create a calculated field named as Regex String (AND) including the following formula.
    "(?=.*" + REPLACE([Search Terms (Comma Separated)], ',', ")(?=.*") + ").*"
  2. Create a calculated field named as AND Filter including the following formula.
    REGEXP_MATCH([Product Name],[Regex String (AND)])
  3. Place Product Name to rows and AND Filter to filters, then select True.
OR Search
  1.  Create a parameter named as Search Terms (Comma Separated).
  • Data type: String
  • Current value: keep it blank.
  • Allowable values: All
  1. Create a calculated field named as Regex String (OR) including the following formula.
    "(" + REGEXP_REPLACE([Search Terms (Comma Separated)], ',', '|') + ")"
  2. Create a calculated field named as OR Filter including the following formula.
    REGEXP_MATCH([Product Name],[Regex String (OR)])
  3. Place Product Name to rows and OR Filter to filters, then select True.

 
Did this article resolve the issue?