The Formula tool creates a new column, or updates a column, using one or more expressions to perform a variety of calculations and operations. See Functions for a list of functions to use when building an expression.
Use the Formula tool to:
- Apply conditional statements
- Convert numbers and strings
- Format dates
- Extract file paths
- Apply financial algorithms or mathematical calculations
- Find minimum and maximum values
- Analyze spatial data
- Cleanse string data
- Perform validation tests on data
Configure the tool
In the Configuration window, select an Output Column of data in Select Column; choose an existing column or add a new column.
Click the expression editor and build an expression. Once the workflow has been run, the Data Preview box displays the first row of data from the specified column with the expression applied.Build an expression
Use any of these methods to build an expression:
- Type directly in the expression editor.
- Press Ctrl + Space to view a list of all functions.
- Type a word or phrase to view a matching list of functions.
- Type a [ (left bracket) to view a list of variables that can be used in the expression.
- Columns: Data from an incoming connection, or from a column created in a previous expression.
- Connections from Questions: Values from an Interface tool connected to the Question anchor of a tool with an expression editor, when the tool is used in an app or macro. Use the Question anchor when you want question values to be used as variables in the expression. See Interface Tools.
- Constants: Global variables for a workflow that make it possible to change a value in a single location and have that change apply to the rest of the workflow. See Constants.
- Click Functions to search and browse through categories of functions. See Functions.
- Click Columns and Constants to search and browse through incoming or newly created columns and constants.
- Click Recent and Saved Expressions to search and browse through recent and saved expressions.
Once an expression has been built, it can be saved for use at a later time.
With an expression in the expression editor, click Save Expression, type a name, and click Save.
It is helpful to add multiple expressions to a single Formula tool when modifying data in related columns or performing similar operations. When modifying unrelated data or performing unrelated functions, using multiple Formula tools assists with workflow troubleshooting.
To add an expression, click Add Expression.
The sequence that expressions are applied affects the results when multiple expressions modify the same data.
To reorder an expression, click and hold and drag up or down.
Because this tool includes an expression editor, an additional input anchor displays when the tool is used in an app or macro workflow. Use the Interface tools to connect to a Question anchor. See Interface Tools.