Built-in Functions → like

like() is a boolean function that returns true if a string pattern can be found in a given string.

Note

The like() function evaluates field and searches for an instance of pattern. It returns true if it finds a pattern in the field and stops searching. If a pattern is not found in the field, like returns false.

Signature

like(string expr field, string pattern, [string esc])
  • field : string expression to search
  • pattern : string to search for (case-sensitive)
  • esc : string

Returns

boolean

Example

Find the number of times the country name contained in U shows up in a given table.

count(like(Sales_Acme.Countries.COUNTRY_NAME, 'U%'))
Important

Before 2024.1.0, the like() function did not handle trailing patterns properly as it returned true when the field contained the pattern regardless of the place of the matching characters. For example, this formula like(Sales_Acme.Countries.COUNTRY_NAME, '%U') would return true for the following country names: UNITED STATES, TURKEY, and PERU while it should return true only for PERU. After upgrading to 2024.1.0 or later releases, you must load all tables that use this function from staging.