How can we help?

Calculate value action

Netanel Hugi
Netanel Hugi
  • Updated

Introduction

The Calculate value action runs an Excel-style formula on your workflow data and produces a single new value you can reuse later in the same workflow - a label, a number, a date, or a piece of text you derive on the fly instead of just passing fields through as they arrived. Any token from the trigger or an earlier action can feed the formula, whatever its type. It pairs naturally with the Transform Data action, and like every action it lives inside a workflow you build on the Workflows page.

How to Use?

Start by creating a workflow in Torii from the Workflows page and add a trigger, then add a Calculate value action to the flow and configure it with the steps below.

Step 1 - Add a Calculate value action

When adding an action to your workflow, search the action picker for calculate and select Calculate value. Its subtitle, Run an Excel-style formula on workflow data, confirms you have the right one.

Action picker with the search term calculate showing the Calculate value action and its subtitle Run an Excel-style formula on workflow data

Step 2 - Add a description (optional)

Give the action a short Description so you can recognize it later - this is also the name Torii uses when it offers the action's result as a token in later steps. In our example we use Tenure label.

Description field filled in with the text Tenure label

Step 3 - Write the formula

In the Formula field, write the calculation you want to run. Rather than typing field names by hand, type @ anywhere to open the token picker and pick the field you want - here we choose the user's start date - and Torii inserts the token into the formula for you. The hint text is a reminder: Use @ to insert tokens. Example: LEN(@First name).

Formula field containing the tenure formula, with Functions, Create with AI, and Test buttons underneath

Not sure which functions are available? Click ƒ Functions to open the palette, search by name, and click any function to append it to your formula. Each entry shows its signature and a short description.

Functions palette titled FUNCTIONS CLICK TO APPEND with a search box filtered to DATE, showing CONVERT_TIMEZONE, DATEDIF, DATE_ADD, and FORMAT_DATE with their descriptions

Step 4 - Create with AI (optional)

If you would rather describe the calculation in plain language, click Create with AI and type what you want the formula to do.

Create with AI panel titled Describe the calculation with a plain-language prompt typed in and a Generate button

Click Generate and Torii opens a panel with the suggested formula and a short explanation of what it does. Click Insert to drop it into the Formula field, or Try again to regenerate from the same description. Once inserted, you can edit and Test it exactly like a formula you wrote by hand.

AI suggested formula panel showing a generated IF/DATEDIF formula with a plain-language explanation and Insert and Try again buttons

Step 5 - Test the formula

Click Test to try the formula with sample values before you save. Fill in a value for each token, click Run test, and Torii shows the Result previewed as the action's selected return type. In our example a start date of 2023-01-01T00:00:00.000Z returns Veteran.

Test formula panel previewing as Text, with a sample start date value and a green Result Veteran

Step 6 - Choose a return type and error handling

Pick a Return type so Torii knows how to interpret and store the result: Number, Text, Boolean, or Date. Text is the default. Your choice also shapes how the result can be filtered in later If/Else branches - a Boolean result is matched as Yes/No, a Number with comparators like > and <, and Text or Date with their own operators - so pick the type that matches how you plan to use the value downstream.

Return type dropdown open with Text selected and options Number, Text, Boolean, and Date

Then choose what should happen On error if the formula cannot be evaluated at run time: Fail workflow, Continue and return blank, or Continue and return fallback value.

On error dropdown open with Fail workflow selected and options Continue and return blank and Continue and return fallback value

If you pick Continue and return fallback value, an extra Fallback value field appears so you can specify exactly what the action returns when the formula fails. A Continue on error toggle is also available in the footer of the action.

On error set to Continue and return fallback value, revealing an empty Fallback value field

A worked example

Here is the full formula we built above, which labels a user as a veteran or a new hire based on how long ago they started:

IF(DATEDIF([Trigger.User.Details.Start-Date], TODAY(), "D") > 365, "Veteran", "New hire")

The above will:

  1. Read the user's start date from the [Trigger.User.Details.Start-Date] token - for example 2023-01-01.
  2. Evaluate DATEDIF(..., TODAY(), "D"), which counts the number of days ("D") between the start date and TODAY().
  3. Compare that day count against 365 with > 365, which is true only when the user started more than a year ago.
  4. Have IF(...) return "Veteran" when the comparison is true, and "New hire" otherwise.
  5. With a start date of 2023-01-01, the day count is well over 365, so the result is Veteran - exactly what the Test panel previews.

Using the result in later actions and branches

Once the action is configured, its output is available to every later action as a token named Result under this action, labeled with the description you gave it. For example, you can drop Calculate value - Tenure label → Result straight into the body of a Send email action with the @ picker.

Send email body showing the token chip Calculate value - Tenure label arrow Result inserted after @tenure

The result can also drive branching: add an If/Else branch after the action and pick the Result token as the condition field, then give each branch its own follow-up actions. In our example, the Veteran branch sends an anniversary note while the other routes new hires into an onboarding sequence - one formula, two paths.

If/Else branch after the Tenure label Calculate value action: the condition panel sets Tenure label Result is Veteran, and the canvas shows the Branch 1 and None met paths each continuing into a Send email action

Use cases

Formulas can mix any token types - here are practical examples using real workflow tokens. The exact token names come from your own triggers and fields, so use the @ picker to grab the equivalents in your workflow.

Renewal-window flag - Label contracts whose renewal date falls within the next 30 days.

IF(DATEDIF(TODAY(), [Trigger.Contract.Details.Renewal-Date], "D") <= 30, "Renewing soon", "Not urgent")

Annual cost per seat - Divide a contract's yearly cost (a currency field) by its seat count and round to two decimal places.

ROUND([Trigger.Contract.Details.Yearly-Cost] / [Trigger.Contract.Details.Seats], 2)

Uppercase full name - Join a user's first and last name with a space and force the whole thing to uppercase for a display field.

UPPER(CONCATENATE([Trigger.User.First-name], " ", [Trigger.User.Last-name]))

Email domain - Pull just the domain out of a user's email address.

MID([Trigger.User.Email], FIND("@", [Trigger.User.Email]) + 1, LEN([Trigger.User.Email]))

Plan tier from seat count - Bucket a contract into a plan tier using the first condition that matches.

IFS([Trigger.Contract.Details.Seats] >= 100, "Enterprise", [Trigger.Contract.Details.Seats] >= 25, "Business", TRUE, "Starter")

Key-account flag - Flag contracts that are both high-spend and large by seat count, then branch on the answer.

IF(AND([Trigger.Contract.Details.Yearly-Cost] >= 10000, [Trigger.Contract.Details.Seats] >= 50), "Key account", "Standard")

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request