Built-in Functions → contains

contains() is a boolean function that returns true if a field expression contains any of the specified strings, find1, find2,..., otherwise, it returns false.

Note

The contains() function is not case sensitive.

Signature

contains(field exp, find1, find2, ...)

The following table illustrates the contains() boolean function parameters:

ParameterDescription
field expThe input field
find1, find2, ...The string value(s) to find in the field exp

Returns

boolean

Example

Find all countries that start with the b, g, or, s characters.

contains(
SALES.COUNTRIES.COUNTRY_NAME,
"b",
"g",
"s"
)

Use the following steps for detailed instructions on how to use the contains() boolean function:

Note

In the Cluster Management Console (CMC), you can create a tenant that includes Sample Data. The Sample Data includes the SALES schema.

  • In the Navigation bar, select the Content tab, and then select + New → Add Dashboard.
  • In the Add Dashboard dialog, for Name, enter Product Dashboard, and then select Add.
  • In the Action bar, select + (add icon), or select + Add Insight.
  • In the Insight panel, select Listing Table or V.
  • In Tables, select Aggregated Table.
  • In the Data panel, select Manage Dataset.
  • In the Manage Data Sets panel, in Tables, select SALES. Close the panel.
  • From the Data panel, drag and drop the following columns to the respective tray:
    • Country from the COUNTRIES table to the Grouping Dimension tray
    • Revenue from the SALES table to the Measure tray
      • In the Properties panel, for Number Format, select Dollar Rounded.
  • From the Data panel, drag and drop Add Formula to the Grouping Dimension tray.
  • The Formula Builder automatically opens:
    • In Search Functions, select the down arrow, and then select Boolean Functions.
    • Double-click the contains function, contains(field exp, find1, find2, ...), to add the formula to the editor.
    • In the Formula Editor,
      • Replace field exp with Country from the Data panel
      • Replace find1 with “b”
      • Replace find2 with “g”
      • Replace ... with “s”
contains(SALES.COUNTRIES.COUNTRY_NAME, "b", "g", "s")
  • Select Validate & Save.
  • In the Properties panel, for Column Label, enter contains()
  • Name the insight Revenue Per Country.
  • In the Action bar, select Save.