In HubSpot, calculation properties allow you to calculate the minimum, maximum, count, sum, or average value of properties on associated records or create custom equations based on other properties.
It is possible, for example, to create:
Please note: depending on your HubSpot subscription, there is a limit to the number of calculation properties you can create.
You can set up calculation properties based on different criteria, such as the property values of associated records, the time between two properties' values, or your own formula. In order to create a calculation property, follow these steps:
An object can have properties calculated based on certain property values of its associated records. You can calculate based on all associated records of that object or for specific association labels, including same object associations.
As an example, you could create a deal property that counts the total number of sales activities logged for a deal's associated contacts.
Please note: An exchange rate will not be applied automatically when using a record currency.
It is possible to create properties that calculate the time between two selected date picker properties within the same object. The time between when a ticket's owner was assigned and when it was closed, for example, can be calculated.
When displaying values for time between calculation properties, the following behavior is expected:
Please note: within HubSpot, the raw values of Time between and Average property types are stored in milliseconds. If an equation with these values yields a higher value than expected, use a millisecond converter to convert to your desired unit of time.
Calculation properties specify how to round number values of other properties. Calculation properties can round commission properties to the nearest two decimal places, for example.
Please note: using a record currency only affects how the value is displayed, and will not automatically apply an exchange rate.
Please note: for currency properties, this feature will round the value to the precision chosen, but will still display values as a currency with the correct amount of digits.
Alternatively, you can create properties that calculate values based on your own criteria. In order to create a custom equation, you must be creating the new property within the same object as the one for which you are creating the new property. You can calculate the amount from a company's most recent deal (Most recent deal amount) in relation to how many times your business contacted the company.
You can build your custom equation with arithmetic operators, comparison operators, logic operators, conditional statements, and other functions. These equations can return number, boolean, string, or date values. Learn more about the available operators and functions, and how to format your formulas.
To build a custom equation calculation property:
Please note: You will not be able to create the property if the output type does not match the output type shown in the top right corner of the editor. Number or date output types determine how values are displayed for properties returning dates (e.g. number displays date in milliseconds, date displays formatted date).
Please note: using a record currency only affects how the value is displayed, and will not automatically apply an exchange rate. To add an exchange rate, you can include the exchange_rate or dated_exchange_rate functions in your equation.
Please note: The calculation won't run if any of the number properties in a custom equation have no value, or a null value. Even if the equation includes a constant number, the value will be empty. In this situation, can use the if and is_known functions to set the value to 0 instead.
With the formula editor, you can create your own equations using literal data, data from other properties, operators, and functions. Below, learn about the syntax for writing custom calculation equations and review examples of commonly used formulas.
By using literal data, you can add text strings, numbers, and true or false values to your equations. Strings, numbers, booleans, and date constants can be formatted in the following ways:
You can include other properties of the same object in your custom equation. If a property is inserted into the editor, it is automatically formatted and validated as part of an equation.
If you choose to manually type or paste a property into the editor, it should be formatted as [properties.{propertyInternalName}]. For example, to add the property Test score, which has an internal value of Test_score, you'd type it into the editor as [properties.Test_score].
When using enumeration properties in an equation (e.g., dropdown select, radio select), values are considered strings, so must be wrapped in double quotes. For example, "subscriber".
Constants and property values can be updated, evaluated, or compared using operators in your equation. Multiple operators follow the PEMDAS order of operations when using multiple operators. You can use the following operators in your custom equations, depending on the type of data you're using.
Operator |
Description |
+ |
Add numbers or strings. Returns a number. |
- |
Subtract numbers. Returns a number. |
* |
Multiply numbers. Returns a number. |
/ |
Divide numbers. Returns a number. |
< |
Checks if a value is less than another. Supported by number properties or constants. Returns a boolean. |
> |
Checks if a value is greater than another. Supported by number properties or constants. Returns a boolean. |
<= |
Checks if a value is less than or equal to another. Supported by number properties or constants. Returns a boolean. |
>= |
Checks if a value is greater than or equal to another. Supported by number properties or constants. Returns a boolean. |
! |
Checks if none of the values are true. Returns a boolean. |
= or == |
Checks if a value is equal to another. Supported by numbers and strings. Returns a boolean. |
!= |
Checks if a value is not equal to another. Supported by numbers and strings. Returns a boolean. |
or or || |
Checks if either of two values are true. Returns a boolean. |
and or && |
Checks if both values are true. Returns a boolean. |
Functions enable you to calculate values and complete actions with your data within custom formulas. You can include the following functions in your custom equations based on the type of data you are using.
Function |
Arguments |
Examples |
abs Get the absolute value of numbers. Returns a number. |
abs(number) number: the number for which you want to get the absolute value. |
abs(-100) = 100 |
concatenate Combine up to 100 strings into one value. Returns a string. |
concatenate("arg 1", "arg 2") arg1: the string to which arg 2 will be appended. arg2: the string to append to arg 1. |
concatenate("Example", " Test") = "Example Test" |
contains Filter strings that contain a specific sequence of characters. Returns a string. |
contains(property, text) property: the property whose values you want to check for the text. text: the sequence of characters that the values should contain. |
contains([properties.name], "Spot")= HubSpot |
currency_decimal_places Get the number of decimal places for a currency. Returns a number. |
currency_decimal_places(currency) currency: the currency string for which you want to calculate the number of decimal places. |
currency_decimal_places("USD") |
dated_exchange_rate Get the value of an exchange rate at the given time. Returns a number. |
dated_exchange_rate(currency, date) currency: the currency string for which you want to calculate the exchange rate on a specific date (e.g., "USD"). date: the datetime property for which you want to calculate the exchange rate. |
dated_exchange_rate("USD", [properties.closedate]) |
exchange_rate Get the most recent exchange rate. Returns a number. |
exchange_rate(currency) currency: the currency string for which you want to calculate the exchange rate. |
exchange_rate("USD") |
if Set up a conditional expression. |
if(condition, arg2) or if(condition, arg2, arg3) condition: the boolean statement that determines what the calculated value will be. arg2: a boolean, number, or string that will be the calculated value if the condition is met. arg3 (optional): the calculated value if the condition is not met. If included, it must be the same type as arg2. If not used, the value will be null when the condition is not met. |
if([properties.amount] > 1000, "large", "small")
|
is_known Determine if a value is known for the token. Returns a boolean. |
is_known(property) property: the property you want to check for a value. |
is_known([properties.name]) = true |
last_updated Get the date of when the token was last updated. Returns a timestamp in milliseconds as a string. |
last_updated(property) property: the property for which you want to check the most recent update date. |
last_updated([properties.amount]) = "1672531200000" |
lowercase Change all characters to lowercase. Returns a string. |
lowercase(text) text: the string or text property with values you want to change to lowercase. |
lowercase("heLLo") = "hello"
|
max Get the maximum of two numbers. Returns a number. |
max(arg1, arg2) arg1: the first number or number property. arg2: the second number or number property. |
max(500,[properties.amount]) = 500, if the amount value is less than 500. |
min Get the minimum of two numbers. Returns a number. |
min(arg1, arg2) arg1: the first number or number property. arg2: the second number or number property. |
min(500, 250) = 250 |
month Get the numeric month of a given date. Returns a number. |
month(date) date: the datetime property for which you want to calculate the month. |
month([properties.closedate]) |
number_to_string Convert a number to a string. Returns a string. |
number_to_string(number_to_convert) number_to_convert: the number or number property you want to change to a string. |
number_to_string(1000) = "1000" |
pipeline_probability Get the probability of a pipeline stage. Returns a number. |
pipeline_probability(pipeline) pipeline: the name of the pipeline for which you want to calculate the probability. |
pipeline_probability("newdeal") |
power Raise a number to the value of another number. Returns a number. |
power(base, exponent) base: the base number. exponent: the value to raise the base to. |
power(5, 2) = 25 |
round_down Round a number down to a specified precision. Returns a number. |
round_down(number_to_round, precision) number_to_round: the number or number property you want to round down. precision: the number of decimal places to round down to. |
round_down(4.353, 1) = 4.3 |
round_nearest Round a number to a specified precision. Returns a number. |
round_nearest(number_to_round, precision) number_to_round: the number or number property whose values you want to round. precision: the number of decimal places to round to. |
round_nearest(4.32, 1) = 4.3 |
round_up Round a number up to a specified precision. Returns a number. |
round_up(number_to_round, precision) number_to_round: the number or number property whose values you want to round up. precision: the number of decimal places to round up to. |
round_up(4.353, 1) = 4.4 |
sqrt Get the square root of a number. Returns a number. |
sqrt(number) number: the number for which you want to get the square root. |
sqrt(144) = 12 |
starts_with Filter strings that begin with a specific sequence of characters. Returns a string. |
starts_with(property, text) property: the property whose values you want to check for beginning characters. text: the sequence of characters that the values should begin with. |
starts_with([properties.name], "Hub") = HubSpot |
string_to_number Convert a string to a number. Returns a number. |
string_to_number(string_to_convert) string_to_convert: the string or text property whose values you want to convert to a number. |
string_to_number("1000") = 1000 |
time_between Get the time difference between two dates. Returns a number. |
time_between(date1, date2) date1: the starting datetime property. date2: the end datetime property. |
time_between([properties.createdate],[properties.closedate]) |
uppercase Change all characters to uppercase. Returns a number. |
uppercase(text) text: the string or text property you want to change to uppercase. |
uppercase("hello") = "HELLO" |
year Get the numeric year of a given date. Returns a number. |
year(date) date: the datetime property for which you want to calculate the year. |
year([properties.closedate]) |
The following are example formulas based on common use cases.