Looker Studio Function : STARTS_WITH
STARTS_WITH Function in Looker Studio – Practical Guide with Examples
Category: Text Function
The STARTS_WITH function in Looker Studio is a text function used to check whether a text value begins with a specific word or character sequence. It returns TRUE or FALSE based on the condition. This function is extremely useful when working with structured text values such as order IDs, campaign names, URLs, product codes, or reference numbers.
In real-world reporting, many datasets follow naming conventions where the starting portion of a text field indicates important information. For example, an order ID may start with a region code, or a campaign name may start with a platform identifier like “FB_” or “GOOG_”. STARTS_WITH allows analysts to identify such records easily without modifying the data source.
From a BI perspective, this function is commonly used in calculated fields, filters, and conditional logic. It is simpler and more readable than regex-based functions for prefix matching. Since it evaluates data row by row and is case-insensitive, it performs efficiently on large datasets.
Overall, STARTS_WITH is ideal for prefix-based classification and filtering in Looker Studio dashboards.
Purpose of STARTS_WITH
1. Prefix Identification
Identifies whether a text value begins with a specific keyword or character sequence.
2. Data Classification
Helps classify records based on standard prefixes used in naming conventions.
3. Conditional Logic
Supports IF or CASE logic by returning TRUE or FALSE based on prefix match.
4. Filtering Support
Enables efficient filtering of records using beginning text patterns.
Type of Calculation & Practical Use Cases
1. Boolean Calculation
Returns TRUE or FALSE based on whether text starts with a specified value.
2. Calculated Dimensions
Used to create calculated dimensions for prefix-based grouping.
3. Dashboard Filters
Helps apply filters based on structured naming prefixes.
4. Data Validation
Validates whether text fields follow predefined naming rules.
STARTS_WITH(text, prefix)
STARTS_WITH Function – Parameters Table
| Parameter | Type | Description |
|---|---|---|
| text | Text | The text value to be evaluated |
| prefix | Text | The starting text or characters to match |
How Does the STARTS_WITH Work?
STARTS_WITH checks the beginning portion of the given text value and compares it with the specified prefix. If the text starts exactly with the given prefix, the function returns TRUE; otherwise, it returns FALSE.
The function is case-insensitive, meaning “ORD” and “ord” are treated the same. It evaluates each record independently, ensuring consistent results across large datasets. If the text value is NULL, the function typically returns FALSE.
When Should You Use STARTS_WITH Function?
When identifying records using fixed prefixes
When validating naming conventions
When filtering or grouping based on starting text
When avoiding complex regex logic
When working with structured text fields
Examples of STARTS_WITH Function
Example 1: Identify Facebook Campaigns
STARTS_WITH(Campaign_Name, "FB_")
Example 2: Validate Order ID Prefix
STARTS_WITH(Order_ID, "ORD-")
Example 3: Use with IF Condition
IF(STARTS_WITH(Channel, "Paid"), "Paid Traffic", "Organic Traffic")
Tips & Best Practices
Use STARTS_WITH for simple prefix checks
Avoid regex when prefix logic is straightforward
Test prefix logic using table views
Combine with CASE for multiple prefix rules
Keep prefixes consistent in source data
No, STARTS_WITH is case-insensitive, so uppercase and lowercase characters are treated the same during prefix matching.
STARTS_WITH checks simple prefixes, while REGEXP_MATCH validates full text using complex regular expression patterns.
No, it returns only TRUE or FALSE, making it suitable for logical conditions and filters.
If the text value is NULL, STARTS_WITH typically returns FALSE and does not match any prefix.
Avoid STARTS_WITH when prefix rules are complex or dynamic, where regex-based functions provide better flexibility.