Looker Studio Function : CONTAINS_TEXT

Category: Text Function

The CONTAINS_TEXT function in Looker Studio is a very useful text function that helps check whether a specific word or character sequence exists inside a text field. In simple terms, it returns TRUE or FALSE based on whether the given text is found. This function is widely used in real-world dashboards for filtering, classification, and conditional logic.

While working on sales, CRM, and marketing dashboards, we often receive unstructured or semi-structured text data such as campaign names, product descriptions, order remarks, or UTM parameters. CONTAINS_TEXT helps us quickly identify patterns like whether a field contains “Online”, “Retail”, “Discount”, or any keyword relevant to business logic.

Instead of cleaning data at the source level, this function allows analysts to apply logic directly inside Looker Studio. It is especially useful when creating calculated fields, conditional formatting, or custom filters. Since it works at row level, the results are accurate and efficient for large datasets.

Overall, CONTAINS_TEXT is a must-know function for anyone dealing with text-based analysis in Looker Studio.

Purpose of the CONTAINS_TEXT Function

1. Keyword Identification

Helps identify whether a specific keyword exists in a text field, such as campaign type or channel name.

2. Data Classification

Used to classify data into categories like Online vs Offline, Paid vs Organic, etc.

3. Conditional Logic

Supports IF or CASE conditions by returning TRUE or FALSE based on text presence.

4. Smart Filtering

Allows filtering of records based on partial text match instead of exact values.

Type of Calculation & Practical Use Cases

1. Boolean Calculation

CONTAINS_TEXT returns TRUE or FALSE, making it ideal for logical conditions.

2. Calculated Dimensions

Often used inside calculated dimensions for grouping or labeling data.

3. Dashboard Filters

Helps create dynamic filters based on keyword presence.

4. Data Validation

Used to check incorrect or unexpected text patterns in datasets.


CONTAINS_TEXT(text, search_text)

CONTAINS_TEXT Function – Parameters Table

ParameterTypeDescription
textTextThe main text field to search within
search_textTextThe keyword or character sequence to find
 

How Does the CONTAINS_TEXT Function Work?

The CONTAINS_TEXT function scans the given text field and checks whether the specified search text exists anywhere inside it. If the search text is found, the function returns TRUE; otherwise, it returns FALSE.

The matching is case-insensitive, which means “Sales” and “sales” are treated the same. The function evaluates data row by row, so each record is checked independently. This makes it very reliable for dashboards where logic depends on text values.

If either of the parameters is NULL, the function may return FALSE, so it is always recommended to ensure clean text input.

When Should You Use CONTAINS_TEXT Function?

  • When exact text matching is not possible

  • When checking keywords inside long text fields

  • When creating conditional logic using IF or CASE

  • When filtering data based on partial values

  • When classifying unstructured text data

Examples of CONTAINS_TEXT Function

Example 1: Identify Online Orders
CONTAINS_TEXT(Order_Type, "Online")

Returns TRUE if Order_Type contains “Online”.


Example 2: Campaign Classification
CONTAINS_TEXT(Campaign_Name, "Facebook")

Used to identify Facebook campaigns from campaign names.


Example 3: Use with IF Condition
IF(CONTAINS_TEXT(Channel, "Paid"), "Paid Traffic", "Organic Traffic")

Tips & Best Practices

  • Use meaningful keywords for better accuracy

  • Combine with IF or CASE for advanced logic

  • Avoid unnecessary nested conditions

  • Clean text data to avoid unwanted results

  • Test logic using tables before applying to charts

1. Is CONTAINS_TEXT case-sensitive?

No, it is case-insensitive.

2. Can CONTAINS_TEXT return text values?

No, it only returns TRUE or FALSE.

3. Can it be used in metrics?

It is mainly used in calculated dimensions or logical conditions.

4. What happens if the text is NULL?

The function may return FALSE.

5. Can it replace REGEXP functions?

For simple keyword checks, yes. For complex patterns, REGEXP is better.