Formula Operator

Overview

The Formula operator lets you run your data through a calculation and send it to an output. Let's say you're calculating the cost of an insurance plan over time and you know the value for one month. To find the value for a year, you use a Formula operator to multiply your original value by 12. Another common use for this operator is to find percentages of a whole.

You have two options when creating your formula:

  • Creating a static formula using the Formula's Info window.

  • Creating a formula with dynamic values using the operator's argument port.

What You'll Learn

In this article, you'll learn:

Info Window Settings

Here's what the Formula operator looks like, along with its Info window:

And here's a breakdown of each setting in the Info window:

Setting

Description

Label

The name applied to the operator. This label displays within the workflow. Labels should be user-friendly and well associated with the role of the operator.

Formula/Expression

The formula or expression you want to apply to your data. Here, use A to represent your original data. Your original data is anything you bring in through the operator's input port. Let's say you want to multiply your data by 12. To do that, you enter =A*12 in this field.

If you want to use an argument instead of a set value in your formula, use _arg. So, the above formula with an argument looks like this: =A*_arg. In this example, _arg takes the place of 12. Whatever value is set in the argument port goes in its place.

Adding and Configuring a Formula Operator

To show the Formula operator in action, let's look at an example. This example uses a standard monthly insurance rate set in a Number component. Your end-user has the choice of how long they need coverage. From there, a Data Workflow uses a Formula operator to calculate the cost of coverage.

Here's how the completed use case looks in the Module Builder:

Here's how the completed use case looks in Express View:

To set up this use case, you need:

  • 2 Text Field components

  • 1 Initializer component

  • 1 Dropdown component

  • 1 Data Workflow component

To set up your Data Workflow, you need:

  • 2 Input operators

  • 1 Formula operator

  • 1 Output operator

Configure the Text Field Components

Start by adding your Text Field components. Your first Text Field holds the monthly cost of insurance. The second holds the total cost based on how many months of coverage your end-user wants. Since your values here are always monetary, set a dollar sign as the prefix. Your end-users don't need to enter anything in these fields either. So, set them both to disable user input.

1. Drag and drop 2 Text Field components onto your canvas.
2. Enter the following Property IDs and Label Text fields:

Property ID

Label Text

monthlyCost

Monthly Cost

totalCost

Total Cost

3. Enter $ in the Prefix.
4. Set the Disable User Input toggle to ON.

5. Save each component as you add it.

Configure the Initializer Component

Next, add your Initializer component. Every time an end-user opens a new submission, your Initializer places a value of 1000 in your first Text Field. This lets the Initializer manage the monthly cost. If you want to set a new monthly cost, all you have to do is update this Initializer.

1. Drag and drop an Initializer component onto your canvas. Place your Initializer above your Text Fields.
2. Enter initSetCost in the Property ID and Canvas Label Text fields.
3. Select New Submission as the Trigger Type.
4. In the Outputs table, enter the following:
Property ID Type Value

monthlyCost

value

1000

5. Click Save.

Configure the Dropdown Component

Now, give your end-user a way to select how many months they want coverage. Use a Dropdown component for that. This component serves as the argument for your Formula operator.

1. Drag and drop a Dropdown component onto your canvas. Place your Dropdown between your Text Fields.
2. Enter coverageLength in the Property ID field.
3. Enter How many months of coverage do you need? in the Label Text field.
4. In the Option and Values table, enter the following:

Option Label

Data Source Values

6

6

12

12

18

18

24

24

5. Click Save.

Configure the Data Workflow Component

Now you can add your Data Workflow component, bringing your monthly cost into the Data Workflow using an Input operator. A second Input operator brings in your end-user's selection from the Dropdown. Then, a Formula operator calculates the total cost. The final value is sent to your Text Field using an Output operator.

1. Drag and drop a Data Workflow component onto your canvas. Place your Data Workflow below your other components.
2. Enter dwfCost in the Label and Property Name fields.
3. Select Watch from the Trigger Type drop-down.

Configure the First Input Operator

This operator references data from your monthlyCost field.

1. Drag and drop an Input operator onto your Data Workflow canvas.
2. Configure the Input operator's Info window as follows:

Setting

Value

Category

Input

Component

monthlyCost

Required

Yes

Source

Default

Configure the Second Input Operator

This operator draws your end-user's requested coverage length.

1. Drag and drop a second Input operator onto your Data Workflow canvas.
2. Configure the Input operator's Info window as follows:

Setting

Value

Category

Input

Component

coverageLength

Required

Yes

Source

Default

Configure the Formula Operator

This operator multiples the monthly cost (A) by your end-user's coverage length, which serves as the formula's argument (_arg).

1. Drag and drop a Formula operator onto your Data Workflow canvas.
2. Configure the Formula operator's Info window as follows:

Setting

Value

Category

Formula Value

Label

Total Cost

Formula/Expression

=A*_arg

3. Connect the output port (right) of the monthlyCost Input operator to the input port (left) of the Formula operator.
4. Connect the output port (right) of the coverageLength Input operator to the argument port (top) of the Formula operator.

Configure the Output Operator

This operator sends the final cost to your totalCost Text Field.

1. Drag and drop an Output operator onto your Data Workflow canvas.
2. Configure the Output operator's Info window as follows:

Setting

Value

Category

Output

Component

totalCost

Action

value

3. Connect the output port (right) of the Formula operator to the input port (left) of the Output operator.
4. Click Save.
5. Save your module.

Now, preview your module in Express View and make a selection from the Dropdown. Depending on your selection, you see the calculated total cost in the Total Cost field. When you make a new selection, the total cost updates.

Changing a Formula Operator's Settings

You can revisit and make changes to this operator.

1. Click the Data Workflow component.

A 5-button toolbar displays above the component on hover-over.

2. Click the (Settings) button to open the Data Workflow canvas.
3. Click the operator to open its Info Window.
4. Make changes to the operator's settings as needed.
5. Click Save.
6. Save your module.

Copying a Formula Operator

You can make a copy of your operator using familiar keyboard settings. You can copy and paste an exact copy of your operator, matching all settings.

1. Hover over the Data Workflow component.

A 5-button toolbar displays above the component on hover-over.

2. Click the (Settings) button to open the Data Workflow canvas.
3. Click the operator you want to duplicate.
4. On your keyboard, press Command + C (Mac OS) or Ctrl + C (Windows/Linux) to copy the operator.

TIP  You can copy more than one operator at a time. Hold Command or Ctrl on your keyboard and click all the operators you want to copy. Follow the rest of the steps as usual.

5. On your keyboard, press Command + V (Mac OS) or Ctrl + V (Windows/Linux) to paste the copied operator(s) to the Data Workflow canvas.
6. Click Save.
7. Save your module.

TIP  Did you know you can copy an operator and paste it into a different Data Workflow? You'll use the same steps outlined above.

Removing a Formula Operator

Lastly, you can delete this operator from your Data Workflow canvas. You can also use these same steps to delete a connection between two operators.

1. Hover over the Data Workflow component.

A 5-button toolbar displays above the component on hover-over.

2. Click the (Settings) button to open the Data Workflow canvas.
3. Click the operator you want to delete.
4. On your keyboard, press Delete.

NOTE  Once you delete this operator, make sure to connect your remaining operators. If your Data Workflow path doesn't end with an Output or Console operator, your Data Workflow won't work. So, once you delete an operator, make sure to update any remaining paths to end at an Output or Console operator.

5. Click Save.
6. Save your module.