Math processor
Performs calculations on numbers.
The Math processor allows you to perform calculation operations on fields containing numbers. You can compute and calculate values within a field, as well as between fields.
Usage
The Math processor requires one input flow and can generate only one output flow.
Properties
Properties to configure to compute or calculate values from fields.
Property | Configuration |
---|---|
Function name |
|
Fields to process |
Select the field or fields on which you want to apply a function in the list. Tip noteIf you want to apply the same function to multiple fields at once, click the Open dialog icon to open a tree view that allows you to select multiple fields.
|
Create new field | Enable this option to create a new field after applying the function. If you do not enable this option, the existing field will be kept and modified. |
Rename new field | Give a custom name to the newly created field. |
To rename the processor or edit its description, click the Edit icon next to the processor name in the Properties panel.
Example
The data used as source in this example contains data about sales to different customers with details on costs, prices, and number of units sold.
However, it is missing important information that could be used in analytics apps, namely total cost, total revenue and total profit. Using the Math processor you can calculate these numbers by performing operations between columns.
Calculating these three figures will require three processors since only one operation can be performed by a processor:
-
The first processor will be used to multiply the number of units sold by the price of an unit to calculate the total revenue. Select the Add, subtract, multiply, and divide function and Units sold as field to process. Choose x as operator, and use Unit Price as second field to use. Select the Create new field checkbox, and name the new field Total_revenue.
-
Then, the second processor will be used to multiply the number of units sold by the cost of an unit to calculate the total cost. Select the Add, subtract, multiply, and divide function and Units sold as field to process. Choose x as operator, and use Unit Cost as second field to use. Select the Create new field checkbox, and name the new field Total_cost.
-
Finally, the third processor will subtract the total cost from the total revenue to obtain the total profit. Select the Add, subtract, multiply, and divide function and Total_revenue as field to process. Choose - as operator, and use Total_cost as second field to use. Select the Create new field checkbox, and name the new field Total_profit.
Running the data flow will create three new fields with the results of the calculation in the target, and allow you to analyze the data further.