Skip to main content

How to Use Custom Dimension Operators and Functions

Learn how to use Custom Dimension operators and functions in Polar Analytics to transform, categorize, and analyze your data with flexible rule-based logic.

Written by Abby Garland
Updated this week

Overview

Custom Dimensions in Polar Analytics let you segment, label, and transform your data using rule-based logic. They are useful when you want to clean up raw values, group records into meaningful categories, extract parts of text, or build date-based and numeric breakdowns for reporting. The current feature set includes comparison operators, text functions, date functions, math functions, and regex-based pattern matching.

In this article, readers will learn:

  • how Custom Dimension logic works using When, Then, and Else

  • which operators are available and when to use each one

  • how to format text, date, math, and regex functions correctly

  • step-by-step examples for building practical Custom Dimensions in reports

Extended Custom Dimension tutorial


Section 1: Understand Custom Dimension Logic

Before using operators or functions, it helps to understand the structure of a Custom Dimension. Every rule is built from three parts:

  • When: the condition that must be true

  • Then: the value returned when the condition is met

  • Else: the fallback value returned when no conditions match

A single When block can contain multiple conditions. These conditions can be combined with:

  • AND: all conditions must be true

  • OR: at least one condition must be true

Examples:

  • Country is "US" AND Device is "Mobile" returns only mobile users in the US.

  • Country is "US" OR Country is "CA" returns users from either country.

Step by step: build your Custom Dimension logic

  1. Open the Custom Dimension builder.

  2. Add a When condition using the dimension you want to evaluate.

  3. Choose the operator that matches the type of comparison you need.

  4. Enter the value or formula to test.

  5. In Then, enter the output you want Polar to return when the condition is true.

  6. In Else, add a fallback output so unmatched values still return something useful.

  7. Save the Custom Dimension and add it to a report as a breakdown or grouping field.

Available operators

Use operators to compare a dimension 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. Be sure to remove the spaces after each ","

Country is in list "US, CA,UK"

Is not in list

Excludes all values in the list. Be sure to remove the spaces after each ","

Tag is not in list "Test,Sample,Free"


Formatting tip for lists

For Is in list and Is not in list, remove spaces after each comma when formatting the list.


Section 2: Use Functions to Transform Text, Dates, and Numbers

Functions let you return transformed values instead of raw dimension values. They are especially useful for cleaning labels, extracting parts of strings, formatting dates, and making simple calculations directly inside a Custom Dimension.

Text functions

Use text functions to shorten, standardize, combine, or extract text from fields like SKUs, titles, tags, or UTM values.


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"

Step by step: create a text transformation

  1. Add a new Custom Dimension rule.

  2. In When, define the condition that identifies which rows should be transformed.

  3. In Then, enter the function using the correct format.

  4. Use the original dimension or a fallback label in Else.

  5. Save the Custom Dimension and test it in a report.

Example workflow:

  1. Use SKU contains "-" in When.

  2. In Then, enter Left(SKU, '12') if you want the first 12 characters only.

  3. In Else, return SKU so all other values stay unchanged.

Date functions

Date functions help you extract or reshape dates for time-based reporting. When using them, you must specify the date field to use, such as the shared Date dimension or a field like Customer First Order Date or Order Processed Date.

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)


Current Timestamp - Returns the current timestamp in UTC

Format: Current_timestamp()


Example: Current_timestamp() -> "2025-08-28 12:15:32"


Date - Returns the calendar date part of a timestamp

Format: Date(Date)

Example: Date(Date) -> "2025-08-28 12:15:32" -> "2025-08-28"


CONVERT_TIMEZONE - Convert a timestamp in UTC to a target timezone

Format: Convert_timezone(Timezone, Date)

Example: Date(Date) -> "Europe/Paris", "2025-08-28 12:15:32" -> "2025-08-28 14:15:32"


DATEADD - Add a number of days, weeks, months etc. to a date

Format: Dateadd(Date Part, Amount, Date)

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

  • amount: How many of date_part to add (negative values for subtraction)

  • date: The date to operate on

Example Dateadd(Date Part, Amount, Date) -> 'day', 2, '2025-08-28' -> '2025-08-30'


DATEFORMAT - Format a date using Snowflake formatting

Format: Dateformat(Date, Format)

Example: Dateadd(Date, Format) -> '2025-08-28', 'MMMM' -> 'August'


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"

Math Functions

Math functions let you calculate or standardize numeric values in Custom Dimensions.

POW - Calculate the power of a number

Format: Pow(Base, Exponent)

Example: Pow(Base, Exponent) -> 2, 4 -> 16


DIV0 - Calculate the division between two numbers. Fall back to 0 if the denominator is 0.

Format: Div0(Base, Exponent)

Examples:

  • Div0(Base, Exponent) -> 2, 4 -> 0.5

  • Div0(Base, Exponent) -> 6, 0 -> 0


MOD - Calculate the rest of the integer division between two numbers.

Format: Mod(Base, Exponent)

Example: Mod(Base, Exponent) -> 5, 3 -> 2


ABS - Calculate the absolute value of a number.

Format: Abs(Value)

Example: Abs(Value) -> -3 -> 3


ROUND - Round a number.

Format: Round(Value)

Example: Round(Value) -> 1.7 -> 2


FLOOR - Calculate the floor of a number.

Format: Floor(Value)

Example: Floor(Value) -> 1.7 -> 1


CEIL - Calculate the ceiling of a number.

Format: Ceil(Value)

Example: Ceil(Value) -> 1.7 -> 2

Section 3: Use Regex and Real Report Examples

For more advanced use cases, Custom Dimensions also support regex-based extraction through the Regexp(subject, pattern) function. This is helpful when values are embedded inside structured text, JSON-like strings, notes, or tags.


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 ([^ ]*) or ([^"]*)

Pattern

Use when...

Example Target

([^ ]*)

The value ends with a space

Duties: 17.39 GBP

([^"]*)

The value ends with a quote

{"value":"Blue"} in JSON

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

Example: Regexp(Notes, 'Duties and Fees: ([^ ]*)') -> Extracts "17.39" from: Duties and Fees: 17.39 GBP

⚠️ 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.


Conclusion

Custom Dimensions in Polar Analytics give you a powerful way to turn raw data into meaningful, actionable insights. By combining When / Then / Else logic with operators and functions, you can clean, categorize, and transform your data directly within your reports—without needing external tools.

To get the most value, start with simple rules, validate your outputs, and gradually layer in more advanced functions like date formatting, math calculations, or regex extraction. Small improvements in how your data is structured can lead to much clearer reporting and better decision-making.

As you build more Custom Dimensions, you’ll be able to tailor your analytics to match your exact business needs—making your dashboards more intuitive, scalable, and insightful.

Did this answer your question?