Skip to main content

How to Use Custom Dimension Operators and Functions

This article details each operator and function available in Custom Dimensions, what they do, and how to format them correctly.

Abby Garland avatar
Written by Abby Garland
Updated this week

Overview

Custom Dimensions in Polar Analytics give you powerful control over how you segment and categorize your data. By using a combination of operators and functions, you can create dynamic, rule-based groupings tailored to your business needs.

This guide explains:

  • What operators and functions are available

  • How to format them correctly

  • Real-world examples to help you apply them effectively

Extended Custom Dimension tutorial

Custom Dimension Logic

When building a Custom Dimension, you’ll work with three key components:

  1. When – The condition that triggers the rule.

  2. Then – What value to return if the condition is met.

  3. Else – What value to return if no conditions are met.

Each When block can include multiple conditions, which you can combine using:

  • AND – All conditions must be true for the rule to apply.
    Example:
    Country is "US" AND Device is "Mobile" → applies only to mobile users in the US.

  • OR – At least one condition must be true for the rule to apply.
    Example:
    Country is "US" OR Country is "CA" → applies to users from either the US or Canada.

You can mix and match these to create complex, targeted logic.

Custom Dimension Operators

Operators define how a dimension value is compared against a condition.

Operator

Description

Example

Contains

True if the dimension includes a specific value

Product Title contains "Bundle"

Does not contain

True if the dimension excludes a value

SKU does not contain "test"

Contains (case sensitive)

Same as Contains, but case-sensitive

Campaign Name contains "Spring" (won’t match “spring”)

Does not contain (case sensitive)

Case-sensitive exclusion

Country Code does not contain "US"

Is

Exact match

Billing Country is "France"

Is not

Excludes exact match

Device is not "Mobile"

Starts with

Matches a beginning value

SKU starts with "PREM"

Ends with

Matches an ending value

Email ends with "@gmail.com"

Is in list

Matches one of several values

Country is in list "US, CA,UK"

Is not in list

Excludes all values in the list

Tag is not in list "Test,Sample"

Custom Dimension Functions

📝 Text Functions

Text functions help you transform or extract information from text-based dimensions like SKUs, product titles, tags, UTM parameters, and more. These functions are especially useful when you want to clean up, shorten, or isolate certain parts of a text string for clearer analysis and reporting.


Left - Returns the leftmost characters of a string.


Format: Left(value, length)

  • value: The dimension/text you want to shorten (e.g. a SKU, title, or URL).

  • length: The number of characters to keep from the start.

Example: Left(SKU, '4')PREM-123456PREM

  • In the example below, we're splitting the SKU dimension so that any SKU containing a hyphen "-" only returns the first 12 characters:


Right - Returns the rightmost characters of a string.


Format: Right(value, number)

  • value: The dimension/text you want to shorten (e.g. a SKU, title, or URL).

  • length: The number of characters to keep from the start.

Example: Right(SKU, '4')PREM-12341234

  • In the example below, we're splitting the SKU dimension so that any SKU containing a hyphen '-' only returns the first rightmost digit.


Lower - Converts all text to lowercase.


Format: Lower(value)

  • value: The dimension you want to convert

Example: Lower(Country Code) → "RO" becomes "ro"

  • In this example, we created a function that will return the Billing Country Code "RO" to lowercase "ro". All other billing country codes will return the default code.


Upper - Converts all text to uppercase.


Format: Upper(value)

  • value: The dimension you want to convert

Example: Upper(Campaign Name) → "summer sale" becomes "SUMMER SALE"

  • In this example, we created a function that will return any campaign names that contain "Au" as uppercase. All other campaigns will return their default name.


Concat - Combines two dimensions or strings.


Format: Concat(value1, value2)

  • value1: The first dimension or text string you want to pull in

  • value2: The second dimension or text string you want to pull in

Example: Concat(Country Code, Zip Code) → "IL" + "90210" → "IL90210"

  • In this example, we're combining the Billing Country Code and Billing Zip for all of the values where the Billing Country Code is "IL".


Trim - Removes leading and trailing whitespace.


Format: Trim(value)

  • value: The dimension to be trimmed

Example: Trim(Product Title)" Deluxe Watch " becomes "Deluxe Watch"


Replace - Replaces a dimension or string of text with a defined value or dimension


Format: Replace(subject, pattern, replacement)

  • subject: The dimension you want to target

  • pattern: The substring that you want to replace

  • replacement: The value used as a replacement

Example: Replace(Product Title, 'Trial', 'Standard')"Trial Kit" becomes "Standard Kit"


Split Part - Splits a dimension or a string of text into parts using a delimiter and returns the selected part.


Format: Split_part(string, delimiter, partNumber)

  • string: The dimension or text to be split into parts

  • delimiter: The text representing the delimiter to split by

  • partNumber: The requested part of the split (starts at 1)

Example: Split_part(SKU, '-', '2')"PREM-01-GOLD" returns "01"

📅 Date Functions

Date functions let you manipulate and extract specific parts of a date, such as the year, month, or day. You can use them to group data by time periods, compare time-based behaviors, or create custom labels for cohorts or timelines.

When using date functions, you need to specify which date to use. This will typically be a dimension like:

  • Date → the shared date dimension that automatically uses the date range selected in your report.

  • Customer First Order Date, Order Processed Date, etc. → specific dimensions from your data.


Day - Returns the day of the month.

Format: Day(date)

Example: Day(Order Date)"2022-04-10"10


Week / Month / Quarter / Year - Assigns a number to the week, month, quarter, or year.

Format: Week(date) / Month(date) / Quarter(date) / Year(date)

Example: Week(Date)"2022-04-10"15


Day Name - Returns the name of the weekday.

Format: DayName(date)

Example: DayName(Date)"Tuesday"


Day of Week - Returns a number from 0 (Sunday) to 6 (Saturday).


Format: DayOfWeek(date)

Example: DayOfWeek(Date)"2022-04-10"0 (Sunday)


Date Diff - Returns the difference between two dates.

Format: Datediff(date_part, date1, date2)

  • date_part: The unit of time (year, month, day, quarter)

  • date1: The first value to compare

  • date2: The second value to compare

Example: Datediff('day', Processed date, Updated day)"2022-01-01" and "2022-01-10" = 9


Date Trunc - Rounds a date down to the specified granularity.


Format: Datetrunc(date_part, date)

  • date_part: The unit of time (year, month, day, quarter)

  • date: The date to be truncated

Example: Datetrunc('month', date)"2022-01-15""2022-01-01"

🔍 Advanced Pattern Matching

Pattern matching functions allow you to detect or replace specific characters, symbols, or patterns in text. These are useful when working with structured text (like SKUs or tags) or when you need to find certain words or values across your data. They're especially powerful for cleaning, standardizing, or categorizing data dynamically.


Regexp - Extracts text based on a regex pattern.


Format: Regexp(subject, pattern)

  • subject: The dimension or string on which you want to apply the regex

  • pattern: The regular expression or the text that precedes the string you want to extract followed immediately by ([^"]*)

Example: Regexp(Order Line Properties, '{"name":"Color","value":"([^"]*)') -> Extracts "Blue" from: [{"name":"Color","value":"Blue"}]

⚠️ Tip: If copying ([^"]*), ensure your quotation marks stay straight quotes (") and not curly quotes (“”) — some browsers may auto-format them incorrectly.

Examples

Analyze Total Sales by Day of the Week

If you'd like to break down your Total Sales by the day of the week they were processed (to identify your highest sales days over a given period), you can use a Custom Dimension like this:

📌 What this does:

  • If there's a valid Order Processed Date, it returns the day of the week (e.g. Monday, Tuesday).

  • If no date is available, it returns "No Data - Extend date range" as a fallback.

Note: The specific date range rule applied to the Order Processed Date doesn’t matter much—what’s important is that your report covers a wide enough date range to include meaningful data.

Once this Custom Dimension is created, add it as a breakdown in a Custom Report alongside Total Sales. You’ll instantly see which days drive the most revenue.

📊 Example Insight:
In the sample report below, Saturdays had the highest Total Sales, while Tuesdays had the lowest—helping you identify weekly patterns and plan accordingly.


Add Labels to Week Numbers Using Concat

If you want to track performance by week, labeling your weeks clearly can help you compare trends more easily across months or years.

For example, if you're analyzing sales or sessions on a weekly basis, adding a prefix like "W-" to your week numbers makes charts and tables easier to read and interpret at a glance.

You can do this using the Concat function:

  • Concat ('W-', Week (Date))"2022-04-10"W-15

📌 What this does:

  • Week((Date)) pulls the week number from a date (e.g. "2022-04-10" becomes 15).

  • Concat("W-", ...) adds the "W-" prefix to make the output easier to interpret in your reports.

📊 Tip: This kind of labeling is especially helpful when visualizing data by week in bar charts or tables—clearer labels make insights easier to spot.

Did this answer your question?