Formula Traits

Build custom formulas on various objects.

Formula Traits

Formula Traits allow you to build custom formulas on various objects. This feature will be available for all objects! Formula Traits enable users to perform basic mathematical operations, if/than (ternary) operations, and comparisons, providing greater flexibility and power in data management.

Creating a Formula Trait

How ToHow To Visual

How to create a Formula Trait:

  1. Navigate to your Settings (⚙️) to find Accounts (Or Organizations)

  2. Then you'll want to select Traits

  3. Name your trait

  4. Add a Description (this will populate when you hover over a trait so staff can see what this trait is)

  5. Select Formula under Type

  6. In the Formula Builder enter the desired formula. The interface will indicate if your syntax is correct with a green "valid syntax" message or highlight errors in red.

    1. Choose your Property, then your Operation, then another Property. Repeat this to build our your formula.

      • A property is a data point in Vitally to choose from

      • The operation is the equation you're using such as adding, equals to, greater than, If/than (ternary), etc.

  7. Select your Formatting

  8. If applicable, select your Number Display (standard number vs currency)

  9. If applicable, select if you want to abbreviate large numbers

  10. Once the syntax is valid, select Create Trait

Previewing your Formula

Underneath the formula builder you have the option to select or search for an object (such as an Account) and the formula builder will use that object’s data to produce a preview of your formula.

That object will persist in the UI, so the next time you build a formula the preview will auto-populate with that object’s values.

If you're updated your Formula Trait, calculations can take from a few minutes to up to an hour.

Operators for Formula Traits

Operators will show you all the formulas currently available for your use. You can also type the notation directly into the formula builder. Currently we allow:

  • Addition

  • Subtraction

  • Multiplication

  • Division

  • If/than (Ternary)

  • Coalesce (returns the first non-null value from a set)

Coalesce Function

Coalesce returns the first non-null value from a list. Coalesce is particularly valuable if you have fields that have null or undefined values and still want to use those fields in a formula.

This is the Coalesce Function Formula: coalesce (a, b, c)

For example, let’s say you introduced new non-recurring revenue service packages to your product offerings. You create a new field for Non-recurring Revenue in Vitally. Some of your customers purchase these packages, so you enter the value $1,200 into that field. But other customers have never purchased a package, and their NRR fields contain no value (not even a zero). If you wanted to build a new formula add your NRR to your ARR, you couldn’t do this for the customers whose values are undefined. In this case, you’d use coalesce to return a zero value.

Coalesce (NRR, 0)

This formula is checking first to see if the NRR fields holds any value. If it holds a value, it will return that value. If the value is null, it will return 0.

If/than (ternary) Formula

The ternary formula allows you to create an if/than statement. It’s a way to specify some outcome if conditions meet a criteria.

Here is the If/than (ternary) Formula: condition ? a : b

For example, let’s say I want to create a formula that determines if one of my accounts is a good candidate for an upsell conversation. To make this determination, I want to evaluate product usage and seat usage. I write my conditions before the ? mark, then I specify what the formula should state if the conditions are true, and what the formula should state if the conditions are otherwise. Here is an example:

(Count of button clicks + Count of downloads) > 20 ? 'Upsell candidate' : 'Not an upsell candidate'

If my product event count is greater than 20, then the formula field will serve me ‘Upsell Candidate’ in the field output. If not, it will serve me a message that says ‘Not an upsell candidate’. To receive this message, the resulting field must be configured to be a string.

Aggregation Traits

Aggregation Traits (previously known as "calculated traits") are calculations of properties on related objects. For example, for a given account, you might want to get the sum of all its related tasks or roll up a trait to use it as a data point on another object. Available aggregations include:

  • Sum - total sum of values

  • Unique - count of distinct values

  • Count all - total count of all items

  • Average - mean value calculated from a set of numbers

  • Rollup - hierarchical summarization of data

Aggregation traits can be used on the Users, Tasks, Active Conversations, Notes, and Custom Objects. Once created, you can use this in Health Scores, automation, Widgets, or anywhere a trait can be used!

How ToHow To Visual

How to create an Aggregation Trait

  1. Navigate to your Settings (⚙️) by selecting your Account Logo on the top left

  2. Scroll down to Data Management and select Traits

  3. Select the Accounts or Organization (if applicable) Traits

  4. On the top right, select Custom Trait

  5. Name your trait

  6. Add a Description (this will populate when you hover over a trait so staff can see what this trait is)

  7. Select Formula under Type

  8. Select Aggregation within the Formula Builder to create your aggregation trait

When there are no objects included in a calculated trait where the operation is sum, average, or a roll up, the value will be set to null instead of zero, allowing traits with no values to be excluded from health scores or filters that ignore nulls.

Complicated Formulas & Use Cases

How to stack if/than statements (nested ternary)

Let’s say you want to create a formula that specifies the output for specific ranges.

If MRR ≥ 8000, show me the value 1 If MRR is between 7999 and 2000, show me the value 2 If MRR is ≤ 1999, show me the value 3

To do this, we’d need to nest more ternaries inside each other. Let’s start by converting each statement into the ternary format. To help us see what we’re doing, let’s also color-code.

MRR(Account) > 8000 ? 1 : (otherwise) *MRR(Account) ≤ 7999 MRR(Account) ≥ 2000 ? 2 : (otherwise) MRR(Account) < 2000 ? 3 : (otherwise)

ℹ️ Notice that to set the conditions for MRR is between 7999 and 2000, you simply place those two statements next to each other.

Now let’s nest them:

MRR(Account) > 8000 ? 1 : (MRR(Account) ≤ 7999 MRR(Account) ≥ 2000 ? 2 : (MRR(Account) < 2000 ? 3 : 0))

In the system, the formula will look something like this:

MRR(Account)>8000 ? 1 : (MRR(Account)<=7999 MRR(Account)>= 2000 ? 2 : (MRR(Account)<2000 ? 3 : 0))
How to build a weighted forecast

There are several ways we could do this! We’ll discuss two possibilities:

  1. The customer has a child object that holds financial information, such as a Deal or an Opportunity

  2. The customer wants to use fields directly on the Account or Org to build their forecast

Lets dig into how we can achieve "The customer has a child object that holds financial information, such as a Deal or an Opportunity":

This formula rolls up critical information from the custom object that represents financial contracts (Opportunities or Deals, for example), and then uses those values to produce a weighted revenue forecast for the Account or Org.

To build this formula, your custom revenue object (we’ll call this the Opportunity for the sake of this example), should have a forecast prediction that aligns to a probability of closure. In this example, we’ll use:

  • Best case - 25%

  • Most likely - 50%

  • Commit - 90%

Now we need to build the formula that gathers these Opportunities and multiplies the dollar value of the opportunity by the probability that it closes.

To do this, we’ll build a roll up. In Vitally’s case, we’re looking for the most recent opportunity, which is why we are choosing a Rollup aggregation ordered by close date. We also want to filter the opportunity to ensure that we’re only getting renewals (as opposed to upsells or cross sells, for example).

Finally, we need to filter for the Forecast Confidence, because this is what will determine the probability multiplier. We will need to create as many rollup aggregations as there are Forecast Confidence types.

Once we have all the aggregations created and multiplied by their confidence values, we should get the weighted forecast.

Our formula becomes:

Rollup Opportunity 'Amount' ordered by 'Close Date' desc2 filters*.25 +
Rollup Opportunities 'Amount' ordered by 'Close Date' desc2 filters*.5) +
Rollup Opportunities 'Amount' ordered by 'Close Date' desc2 filters*.9) ​

Let’s say that the Opportunity is in “most likely”. The resulting formula will be:

 0 + 36,000*.5 + 0 = 18,000

You could also build this formula directly on the Opportunity!

In this case, you’re use if/than logic, or the ternary formula. I’ve color-coded the different logic arguments so that it’s easier to tell them apart.

  • Forecast Confidence == ‘best case’ ? Amount*.1 : (otherwise)

  • Forecast Confidence == ‘most likely’ ? Amount*.5 : (otherwise)

  • Forecast Confidence == ‘commit’ ? Amount*.9 : 0

The resulting formula looks like this:

Forecast Confidence == ‘best case’ ? Amount*.1 : (Forecast Confidence == ‘most likely’ ? Amount*.5 : Forecast Confidence == ‘commit’ ? Amount*.9 : 0 )))

Now onto the second way to build a weighted forecast "The customer wants to use fields directly on the Account or Org to build their forecast":

In this case, you’d use the ternary formula again, but leveraging some field on the Account that helps us understand the probability of close.

Renewal == ‘churn’ ? Amount*.0: (otherwise)

Renewal == ‘at risk’ ? Amount*.5 : (otherwise)

Renewal == ‘commit’ ? Amount*.9 : 0

How do I build a formula that spits out text?

Example: Let’s say you’re trying to identify customers that need retraining, and making this determination by evaluating low product usage. Your formula might pull in different event data; however, you don’t want the CSM to have to know what “too low” means. Further, you might want to tweak the formula over time to hone in on customers that truly need retraining. Therefore, you want the formula to simply spit out the text “retraining candidate”.

In this instance, we’d want to specify the Trait output as string and specify what string should be used in the formula. Ternary is the most helpful formula to use here.

(Count of button clicks + Count of downloads) < 10 ? 'Retraining candidate' : (Null)***

In the above formula, we specify that if the sum of button clicks and downloads is less than 10, the text should say “Retraining candidate.” Otherwise, it should not say anything.

How to use formulas with the Boolean output

Simply specify the conditions that the formula should evaluate. If the conditions are met, the output will be “true” and if they are not, the output will be “false.”

Using Contains and Does not Contain function

These operators are used with multi-select traits in a formula. Contains() is helpful if you’re trying to identify if a multi-select trait has a particular value or set of values applied.

For example, I might have a multi-select field for Champion Type, and the available values to choose from could include "G2 review" "quote" "reference" "promoter NPS" "beta tester". I could use contains() to pull out customers where “quote” has been applied. The formula is written like this:

contains(array, value)

Where the array is the Multi-select Trait, and the value is what you’re looking for. Please note that the formula can only recognize exact matches. So I could not search for ‘G2’ I would be required to search for ‘G2 review’.

If I wanted to search for a mix of the traits, I could stack them up in my conditional statement. In the below, I am searching for the multi-select trait contains both ‘G2 review’ and ‘promoter NPS’ simply by placing those requirements next to each other.

Formula & Aggregation Trait FAQs

Q: What will happen if I build a formula that uses bad syntax? A: When building formulas, the formula builder will tell you if your syntax is acceptable or if it requires adjustment. In the bottom of the formula box you’ll see a note in green that says “valid syntax” if your formula’s syntax is valid, and red text if it is invalid. Users will be prevented from saving formulas that contain invalid syntax.

Q: What if I use unsupported notation? A: If you use a notation that isn't supported, the formula builder will behave the same way as with bad syntax. You'll get an error message, and the formula won't be saved until you fix it.

Q: How quickly will the formulas calculate? A: We calculate the formula immediately upon its creation or after being edited. It should take anywhere between a few minutes to an hour to calculate. You should be able to see in the Trait list in Settings whether the formula has finished calculating for all objects. We reevaluate the formula hourly for non-churned target and daily for churned targets.

Q: Talk to me about building formulas with date properties. A: Currently, formulas between two dates produce large numbers because the output is not set up to display in days. This is an area for future improvement.

Last updated