Math task is used to perform arithmetic operations on the data. This task supports standard BODMAS expression with support for some inbuilt functions.
Let us start with the following data which is a score card of a group of students for three subjects:
Complete the following steps to calculate the total number of Marks that the the students have received:
- Open Data Preparation menu and click on Numeric Functions
- Select Perform Math Function
- In the expression box, build the expression:
Science + French + English
- Enter “Total” into the new column box
- Click APPLY
The result will appear as shown below:
Math task takes the following inputs:
Arithmetic expression accepted by the math tasks supports the following arithmetic operators.
+, -, *, /. These operands work on the following types of operands.
- Functions such as count, sum, avg. See Functions
- Nested expression
Let us assume that your original data is as shown below:
The valid expressions are:
- “Science” + “French”
- (“Science” + “French” + `”English”)/300
- AVG(“Science”) - “Science”
- INT((“Science” + “French” + `”English”)/3)
Note that the column names are put within a quoted string. The application shows hints to guide you to the right expression. If the expression is invalid, a warning is displayed at the bottom right of the expression box.
The expressions can be copied and pasted. You can paste an expression into a normal text editor like notepad, edit it and paste if back. The expression will work if it is valid.
The criterion for valid expression are:
- Referring to the correct column names.
- The braces are correctly opened, and
- The functions used (such as SUM, COUNT) and so on, should have the correct parameters. See documentation for the functions and their parameters.
Expressions can be nested inside one another using parentheses. The following expressions are valid.
- (10 + 20)/(20 + 40)
- (10 - (20 + 40 * (100 -55)) + 20)
- (10 * (20 + 40) + 20)/(“Science” + 10)
You can nest to as many levels. However, it is simpler to add more than one math rule at time to keep it simple and readable.
The results of the arithmetic expression is saved into a new column.
Handling empty values¶
+ - * / operations empty values
are treated as if they are zeroes.