Looker Studio Function : RIGHT_TEXT
RIGHT_TEXT Function in Looker Studio – Practical Guide with Examples
Category: Text Function
The RIGHT_TEXT function in Looker Studio is a text manipulation function used to extract a specific number of characters from the right side of a text value. It is especially useful when working with structured or semi-structured text fields such as order IDs, invoice numbers, phone numbers, file names, or codes where important information appears at the end.
In real-world reporting scenarios, data is often stored in a single combined field instead of separate columns. For example, a product code may contain a fixed prefix followed by a numeric identifier. RIGHT_TEXT helps analysts extract that ending portion quickly without changing the data source.
From a BI perspective, this function is commonly used in calculated dimensions for grouping, categorization, or validation. It works at row level and performs efficiently even on large datasets. RIGHT_TEXT is often used together with LEFT_TEXT or MID to break down complex text values into meaningful components.
Overall, RIGHT_TEXT is a simple yet powerful function that helps analysts clean, structure, and analyze text data directly inside Looker Studio.
Purpose of RIGHT_TEXT
1. Extract Ending Values
Extracts fixed-length values like serial numbers, suffixes, or identifiers from text fields.
2. Data Structuring
Helps separate meaningful information stored at the end of structured text values.
3. Custom Dimension Creation
Creates new calculated dimensions based on right-side text extraction.
4. Simplify Analysis
Reduces complex logic by directly extracting required text segments.
Type of Calculation & Practical Use Cases
1. Text Extraction
Extracts characters from the right side of text values for reporting purposes.
2. Calculated Dimensions
Commonly used to create clean and meaningful calculated dimensions.
3. Data Preparation
Acts as a quick data preparation step inside Looker Studio.
4. Grouping & Validation
Supports grouping and validation based on extracted text values.
RIGHT_TEXT(text, number_of_characters)
RIGHT_TEXT Function – Parameters Table
| Parameter | Type | Description |
|---|---|---|
| text | Text | The text value from which characters are extracted |
| number_of_characters | Number | Number of characters to extract from the right side |
How Does the RIGHT_ TEXT Work?
RIGHT_TEXT reads the given text value from the rightmost character and extracts the number of characters specified. The extracted portion is returned as a text value.
If the requested number of characters exceeds the text length, the entire text is returned. The function processes data row by row, ensuring consistent behavior across datasets. If the input text is NULL, the function returns NULL.
When Should You Use RIGHT_TEXT Function?
When extracting suffixes or serial numbers
When text follows a fixed ending structure
When creating grouping logic based on text endings
When preparing structured dimensions from raw text
When avoiding source-level data changes
Examples of RIGHT_TEXT Function
Example 1: Extract Last Four Digits of Order ID
RIGHT_TEXT(Order_ID, 4)
Example 2: Extract File Extension
RIGHT_TEXT(File_Name, 3)
Example 3: Extract Phone Number Ending
RIGHT_TEXT(Mobile_Number, 4)
Tips & Best Practices
Use RIGHT_TEXT only when text structure is consistent
Verify text length before extraction
Combine with LEFT_TEXT or MID for complex logic
Test results in table views
Keep calculated fields readable and simple
No, RIGHT_TEXT simply extracts characters and does not perform any text comparison or case-based logic.
If the text length is shorter, the entire text value is returned without any error.
No, numeric values must be converted to text before using the RIGHT_TEXT function.
RIGHT_TEXT is mainly used in calculated dimensions for text manipulation and extraction.
For fixed-length extraction, yes. For dynamic or pattern-based extraction, REGEXP functions are better.