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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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:
- Read the user's start date from the
[Trigger.User.Details.Start-Date]token - for example2023-01-01. - Evaluate
DATEDIF(..., TODAY(), "D"), which counts the number of days ("D") between the start date andTODAY(). - Compare that day count against
365with> 365, which is true only when the user started more than a year ago. - Have
IF(...)return"Veteran"when the comparison is true, and"New hire"otherwise. - With a start date of
2023-01-01, the day count is well over365, so the result isVeteran- 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.
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.
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")