When creating Custom Dimensions, there are a number of both functions as well as text operators available to you that enable you to have full flexibility over how your data is segmented. Those functions and operations (and how each one works) are detailed below.
Custom Dimension Operators:
Contains: Applies when a dimension contains a specific value within it
Does not contain: Applies when a dimension does not contain a specific value within it
Contains (case sensitive): Applies when a dimension contains a specific, case sensitive value within it
Does not contain (case sensitive): Applies when a dimension does not contain a specific, case sensitive value within it
Is: Applies when a dimension is exactly a specific value
Is not: Applies when a dimension is not exactly a specific value
Starts with: Applies when a dimension starts with a specified value or sequence
Ends with: Applies when a dimension ends with a specified value or sequence
Is in list: Applies when a dimension is included in a list of specified values
Is not in list: Applies when is not included in a list of specified values
Custom Dimension Functions:
Left: Returns the leftmost values that appear in the text at a defined point. After writing your "When" statement detailing the criteria that you want to trigger this "Left" function, format your "Then" statement as:
Right: Returns the rightmost values that appear in the text at a defined point. After writing your "When" statement detailing the criteria that you want to trigger this "Right" function, format your "Then" statement as:
Lower: Returns the lowercase version of any dimension. Format these statements as:
Upper: Returns the uppercase version of any dimension. Format these statements as:
Concat: Combines two dimensions or strings into one. Format these statements as:
Trim: Trims whitespace from beginnings and ends of dimensions or text. Please note that this function only works if you input a value in your "When" statement that includes spaces at the beginning / end. Format these statements as:
Trim (Dimension you want to trim)
Replace: Replaces a dimension or text with a defined value or dimension. Format these statements as:
Datediff: Returns the difference between two dates. Format these statements as:
Datediff (Granularity needed [granularity can be day, week, month, quarter, year], First date, Second date)
Example: If created date = 2022-01-01 and retry date = 2022-01-10, DATEDIFF(day, created date, retry date) = 9
Datetrunc: Transforms a date into a different granularity of choice. Format these statements as:
Datetrunc (Granularity needed [granularity can be day, week, month, quarter, year], Date you'd like to truncate)
Example: DATETRUNC(’month’, ‘2022-01-15’) = ‘2022-01-01’
Split_part: Splits the dimension or text at a defined point in multiple parts, and returns the values that appear in the defined part before or after that point. Format these statements as:
Split_part (Dimension you want to split, the delimiter where you would like to split it, the part/element number)
In this example, we'd like to see the 2 digits in a SKU that follow the "-". The Custom Dimension below splits any SKUs that contain the dash, and returns the second part after the dash. Any SKUs that do not contain a dash will simply return the default SKU.
Day / Week / Month / Quarter / Year: Each of these functions enables you to assign a number to your days, weeks, months, quarters, or years, to more easily see where you're falling in the year (or multiple years).
For example, if you'd like to number your weeks throughout the year, you'd format that statement as "Date is not null" in the When statement, and Concat ('W-', Week (Date)) in the Then statement. If you'd like to number your days, quarters, or years instead, simply replace "Week" with the function of your choosing.
DayName: This functions names your days of the week so that you can identify performance by weekday for any of your metrics. Format these statements as:
DayName (The dimension you'd like to break down or filter)
This article provides a complete walkthrough on how to set up a dimension using this function.
DayOfWeek: Similarly to the DayName function, this function enables you to assign a number to the days of the week, to quickly compare your data based on weekday performance. When used in a Custom Dimension, this function will return a number 0 - 6 (with 0 being Sunday, 1 being Monday, 2 being Tuesday, etc). Format these statements as:
Dayofweek (The dimension you'd like to break down or filter)
For example, if you'd like to break down your Total Sales by the day of the week they were processed (to see your typical highest sales days for a given date range), you can replicate the Custom Dimension below:
Note that the date rule you set for "Processed Date" doesn't really matter, as long as you have a large enough date range to analyze the dates you're interested in.
From there, once you apply this in a Custom Report, you can add this dimension as a break down in a Custom Report to quickly gain insight into your top sales days. In the example report below, Mondays were the top sales day (for the set date range), and Sundays were the lowest sales day.
Day of Week Key:
0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday
Regexp: This function extracts some text from any other dimension using a search pattern. For example, if you have multiple data points under one dimension (like Product Tags or Order Line Property), you can extract various pieces of information from the line using search rules. To use the Regexp function:
In your “When” statement, choose which dimension you’d like to extract text from. In our example below, we’re using the Order line properties dimension.
In your “Then” statement, enter the formula:
Regexp (Your dimension name, Whatever text precedes the text you want to extract followed immediately by ([^"]*))
Example:
Important note: make sure when copying ([^"]*)) that " sign is correct - some browsers might automatically change the sign to an incorrect one. If you have any issues - feel free to reach out to our Support team via in-app chat.
Extended Custom Dimension tutorial