Custom formula
What you can do with custom formulas
Ratio calculations: Key metrics such as conversion rate, average order value and cost per click
Goal management: Goal attainment rate, actual vs. target, progress tracking
Conditional analysis: Grading and segmentation
String handling: Cleaning, parsing, joining and converting data
Date operations: Extracting year · month · day · week number · weekday · quarter
Compound calculations: Advanced metrics such as ROAS, ROI and net profit margin
Create a custom formula
On the Data tab of the settings panel on the right of the chart editor, choose a data source and measures first.
Under Data tab › Custom formula, click New formula.
In Formula name, enter the name to show in the table and the measure list. (e.g. ROAS)
Enter measures and functions in Expression. Hover over a function or Example in the list on the left to see a description; click it to insert it into the expression.
Under Number format, choose one of Number · Currency · Ratio · Text, then click Save.

Custom formula editor
How it works
Custom formulas work in the following order:
Enter an expression
Syntax check Checks parentheses, quotes and function names, and whether the referenced columns exist in the measures and dimensions currently selected
Calculation Queries data with the selected measures and dimensions, then applies the expression to each row of the result to create a new column
Display results Shows the calculated values on the dashboard
Comparison with Excel
Cell reference
A1, B2:B10
'revenue', 'order_count'
Division
=A1/B1
DIVIDE('revenue', 'order_count')
Condition
=IF(A1>100, "High", "Low")
IF('revenue' > 100, "High", "Low")
Text
="Hello " & A1
CONCAT("Hello ", 'product_name')
Basic syntax
1. Column references
'column_name'
2. Number literals
You can't write a negative number directly as -50. Make it with subtraction, like 0 - 50.
3. String literals
Use double quotes.
4. Operator precedence
() Parentheses Calculated first.
* / Multiplication, division
Calculated before addition/subtraction
+ - Addition, subtraction
Calculated after multiplication/division
> < >= <= Comparison operators
Compared after arithmetic
Operators
Arithmetic operators
+
Add
'revenue' + 'cost'
Revenue + cost
-
Subtract
'revenue' - 'cost'
Net profit
*
Multiply
'quantity' * 'unit_price'
Total amount
/
Divide
'revenue' / 'order_count'
Average order value
Comparison operators
=
Equal to
'status' = "Completed"
<>
Not equal to
'status' <> "Canceled"
>
Greater than
'revenue' > 1000
<
Less than
'revenue' < 1000
>=
Greater than or equal to
'order_count' >= 2
<=
Less than or equal to
'order_count' <= 1
Logical functions
AND and OR are used as functions, not as operators placed between conditions. Writing 'revenue' > 1000 AND 'status' = "Completed" causes an error.
AND
AND(condition1, condition2): both are true
AND('revenue' > 1000, 'status' = "Completed")
OR
OR(condition1, condition2): at least one is true
OR('category' = "Apparel", 'category' = "Accessories")
NOT
NOT(condition): flips true and false
NOT('revenue' > 1000)
You can include up to two conditions. For three or more, nest them like AND(condition1, AND(condition2, condition3)).
Function types
Math functions
MULTIPLY
MULTIPLY(a, b)
Multiplication
MULTIPLY('quantity', 'unit_price')
DIVIDE
DIVIDE(a, b)
Division
DIVIDE('revenue', 'order_count')
SUBTRACT
SUBTRACT(a, b)
Subtraction
SUBTRACT('revenue', 'cost')
ABS
ABS(value)
Absolute value
ABS('profit_loss')
FLOOR
FLOOR(value)
Round down
FLOOR('decimal_value')
CEIL
CEIL(value)
Round up
CEIL('decimal_value')
Conditional functions
IF
IF(condition, true_value, false_value)
Condition
IF('revenue' > 1000, "Excellent", "Average")
IFS
IFS(cond1, val1, cond2, val2, ...)
Multiple conditions. Rows that match no condition are blank
IFS('revenue' >= 10000, "Top", 'revenue' >= 5000, "Excellent")
COALESCE
COALESCE(val1, val2, ...)
Replace NULL
COALESCE('discount', 0)
NULLIF
NULLIF(val1, val2)
NULL if equal
NULLIF('order_count', 0)
String functions
CONCAT
CONCAT(str1, str2, ...)
Join strings
CONCAT('first_name', " ", 'last_name')
UPPER
UPPER(text)
Convert to uppercase
UPPER('product_code')
LOWER
LOWER(text)
Convert to lowercase
LOWER('email')
TRIM
TRIM(text)
Remove spaces
TRIM('address')
LENGTH
LENGTH(text)
String length
LENGTH('product_name')
SUBSTR
SUBSTR(text, start, length)
Substring
SUBSTR('phone', 1, 3)
REPLACE
REPLACE(text, old, new)
Replace text
REPLACE('address', "St.", "Street")
Date/time functions
NOW
NOW()
Current time
NOW()
CURRENT_DATE
CURRENT_DATE()
Today's date
CURRENT_DATE()
DATE
DATE(year, month, day)
Create a date
DATE(2024, 1, 15)
YEAR
YEAR(date)
Extract year
YEAR('time_id')
MONTH
MONTH(date)
Extract month
MONTH('time_id')
DAY
DAY(date)
Extract day
DAY('time_id')
WEEK
WEEK(date)
Extract week number
WEEK('time_id')
DAY_OF_WEEK
DAY_OF_WEEK(date)
Weekday (1=Sun, 2=Mon, ..., 7=Sat)
DAY_OF_WEEK('time_id')
QUARTER
QUARTER(date)
Quarter
QUARTER('time_id')
Regex functions
REGEXP_EXTRACT
REGEXP_EXTRACT(text, pattern)
Extract with regex
REGEXP_EXTRACT('url', "utm_source=([^&]+)")
REGEXP_REPLACE
REGEXP_REPLACE(text, pattern, replacement)
Replace with regex
REGEXP_REPLACE('phone', "[^0-9]", "")
Type conversion functions
CAST
CAST(value, "TYPE")
Type conversion
CAST('amount', "DOUBLE")
Examples
Ratio calculations
Conversion rate (CVR)
(Orders ÷ clicks) × 100
DIVIDE('order_count' * 100, 'clicks')
5.0%
Average order value (AOV)
Revenue ÷ orders
DIVIDE('revenue', 'order_count')
₩ 50,000
Cost per click (CPC)
Ad spend ÷ clicks
DIVIDE('ad_cost', 'clicks')
₩ 200
ROAS
(Revenue ÷ ad spend) × 100
DIVIDE('revenue' * 100, 'ad_cost')
500%
Goal management
Goal attainment rate
(Actual revenue ÷ target revenue) × 100
DIVIDE('revenue' * 100, 'target_revenue')
85%
Goal attainment grade
S (130%↑) / A (110%↑) / B (90%↑) / C (90%↓)
IF(DIVIDE('revenue', 'target_revenue') >= 1.3, "Grade S", IF(DIVIDE('revenue', 'target_revenue') >= 1.1, "Grade A", IF(DIVIDE('revenue', 'target_revenue') >= 0.9, "Grade B", "Grade C")))
Grade A
Difference from target
Actual revenue - target revenue
SUBTRACT('revenue', 'target_revenue')
+ ₩ 2,000,000
Required daily revenue
(Target - current) ÷ days remaining
DIVIDE( SUBTRACT('target_revenue', 'current_revenue'), 'days_remaining' )
₩ 1,200,000/day
Customer segmentation
Customer tiers
Platinum (50K↑) / Gold (20K↑) / Silver (10K↑) / Bronze
IF('revenue' >= 50000, "Platinum", IF('revenue' >= 20000, "Gold", IF('revenue' >= 10000, "Silver", "Bronze")))
Weekend/weekday
Identify weekends by weekday number
IF(OR(DAY_OF_WEEK('time_id') = 1, DAY_OF_WEEK('time_id') = 7), "Weekend", "Weekday")
New/returning customers
Classify customer type by number of orders
IF('order_count' > 1, "Returning", "New")
Age group
35 → "30s"
CONCAT( CAST(FLOOR('age' / 10) * 10, "VARCHAR"), "s" )
Tips and cautions
Recommendations
Cautions
Column reference
revenue or "revenue"
'revenue'
String
'Completed'
"Completed"
Column name typo
'revenu'
'revenue'
Frequently asked questions (FAQ)
Ask your dedicated manager
Having trouble using custom formulas?
Contact us through the inquiry page or by email below. Your manager will be happy to help.
Email: product@laplacetec.com
Last updated