This page provides more information about the use of formulas when creating custom items. To learn more about custom items, go to:
To create a formula for a custom item, you should have already selected the type of custom item, given it a name and selected “Formula” from the Input Type drop down menu. An additional field will then appear:
- Enter a Formula into the field by starting with an “=”.
- You can then also enter variables, numbers and basic mathematical operators such as +, -, *, /, and ( ).
Examples of basic formulas that could be entered in the Formula field are the following:
- = normal_rate * 40 * 25
- = (basic_salary + normal_pay) / 4.3333 * 0.3333
Variables which can be used when creating formulas are:
- basic_salary: Basic Salary (salaried employees)
- normal_pay: Basic Hourly Pay (hourly paid employees)
- normal_rate: Hourly Rate
- shifts_worked: Number of shifts worked
- total_income: Total income
- min: Used to select the lowest of the values in the list provided to it
- max: Used to select the highest of the values in the list provided to it
Example 1: Bargaining Council Levy |
An employer must make a contribution that is 0.32% of the employee’s hourly pay, with a maximum contribution of R4.26. Since there is a maximum, the formula must select the lowest of option (1) which is R4.26 and option (2) which is the employee’s pay multiplied by 0.32%
= min(4.26, (normal_pay*0.0032))
Example 2: Trade Union deduction
An employee must make a contribution of 1% of their hourly pay, plus
R1.80. The minimum contribution is R9.13 and the maximum contribution is R16.73.
= min(16.73, (max(9.13, (normal_pay*0.01)))) + 1.80
General IF statements
The IF function returns one value if the specified condition is true and another IF false. The IF statement is also known as a logical formula: If, then, else. If something is true, then do this, else/otherwise do that.
The IF statement works as follows:
if (condition, true statement, false statement)
For example: Suppose that the company deducts a staff social fund contribution based on how much an employee earns. If the employee’s salary is greater than R10 000, then the contribution is R100, but if the employees earns less than R10 000, then the contribution is R80.
The formula will be written as:
= if (basic_salary>10000, 100, 80)
This means that if the basic salary is greater than 10 000, the result will be 100 and if it’s less it will be 80.
Nested IF statements
A nested IF statement is an IF statement within an IF statement. It works as follows:
if ( condition, true statement , ( if ( condition, true statement, false statement) )
For example: Suppose that the company deducts a staff social fund contribution based on how much an employee earns. If the employee’s salary is greater than R10 000, then the contribution is R100, but if the employees earns between R5 000 and R10 000, then the contribution is R80, and if they earn less than R5 000 it is R60.
The formula will be written as follows:
= if (basic_salary>10000, 100, if (basic_salary<5000, 60, 80)
This means that if the basic_salary is greater than 10 000, the result will be 100. Otherwise, if the salary is less than 5 000, the result will be 60, otherwise it will be 80.