# 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.

Configuration

| Property | Configuration |
| --- | --- |
| Function name | <ul> <li> <p><span>Add</span>: Performs an addition on the field with another field or with a fixed value.</p> </li> <li> <p><span>Modulo</span>: Calculates the remainder of a division operation.</p> </li> <li> <p><span>Absolute value</span>: Calculates the absolute value for all the numeric values in the field.</p> </li> <li> <p><span>Divide</span>: Performs a division on the field with another field or with a fixed value.</p> </li> <li> <p><span>Negate</span>: Negates the field numbers.</p> </li> <li> <p><span>Min</span>: Compares with another field or a constant and returns the smallest value.</p> </li> <li> <p><span>Max</span>: Compares with another field or a constant and returns the largest value.</p> </li> <li> <p><span>Base 10 Logarithm</span>: Computes the base 10 logarithm from the field.</p> </li> <li> <p><span>Multiply</span>: Performs a multiplication on the field with another field or with a fixed value.</p> </li> <li> <p><span>Natural logarithm</span>: Computes the natural logarithm from a field.</p> </li> <li> <p><span>Exponential</span>: Calculates the exponential of the field numbers.</p> </li> <li> <p><span>Power</span>: Multiplies to the power of another field or a constant.</p> </li> <li> <p><span>Square root</span>: Calculates the square root of the field numbers.</p> </li> <li> <p><span>Subtract</span>: Performs a subtraction on the field with another field or with a fixed value.</p> </li> <li> <p><span>Cosine</span>: Computes the trigonometric Cosine from the field.</p> </li> <li> <p><span>Sine</span>: Computes the trigonometric Sine from the field numbers.</p> </li> <li> <p><span>Tangent</span>: Computes the trigonometric Tangent from the field numbers.</p> </li> </ul> |
| Fields to process | Select the field or fields on which you want to apply a function in the list. |
| 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, point your mouse over the name or description to change in the Properties panel and click the Edit icon.

## 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.

![Dataset with the number and price of orders](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Resources/Images/Dataflow/maths_example_1.png)

However, it is missing important information that could be used in analytics applications, 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:

1. 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.

2. 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.

3. 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.

![A data flow with math processors to calculate total profit and cost](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Resources/Images/Dataflow/maths_example_2.png)

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.