Payroll component formulas
How to write, test and fix the formulas in your payroll's salary components.
Use with AI
External services may not be able to read this preview. Use Copy for AI instead.
Availability: To use Payroll, your account must have this feature enabled and your role must have the corresponding permissions. If the option does not appear, contact Aragro support.
Each payroll structure is made of salary components: earnings (salary, seventh-day pay, bonuses), deductions (social security, income tax) and totals. A component can be a fixed amount or a formula. This guide explains how to write those formulas, how to test them before completing the payroll, and how to fix the most common errors.
Before you start
Section titled “Before you start”- Have your employees and their payroll structure ready. If you don’t have one yet, see the Payroll FAQ.
- Write the rule first in words or in Excel, with a real employee as an example and the result you expect. For example: “Juan attended 10 days; his bonus should be Q83.33.” That example is the fastest way to check later that the formula is right.
How a formula is built
Section titled “How a formula is built”Name and abbreviation
Section titled “Name and abbreviation”Each component has a name (shown on the payroll and in reports) and an abbreviation. The abbreviation is what you use to refer to that component inside other formulas, for example Vtrabajo or SeptPlanilla.
- Use short abbreviations without spaces or accents.
- Type them in formulas exactly as you defined them.
- Order the component list logically (base data, earnings, deductions and totals) so it is easy to review from top to bottom.
System variables
Section titled “System variables”Aragro calculates each employee’s data for the period from work orders and absences. These are some of the most used variables; the full list appears in the formula editor’s Available variables panel.
| Variable | What it represents |
|---|---|
attendedDays |
Days attended in the period. |
dailyWageList |
List of the period’s day-wage payments, one per day. |
pieceworkWages |
List of the period’s piecework payments. |
overtimePay |
Overtime pay. |
paidLeaves |
Days of paid leave. |
holidays |
Holidays in the period. |
holidayPay |
Pay for the period’s holidays. |
activityDays |
Days worked per activity. Read it with GETNUM(activityDays, 'code'), using the activity’s code. |
Variables that are lists (for example, dailyWageList and pieceworkWages) are used inside functions such as SUM or COUNT, not on their own.
Functions and operators
Section titled “Functions and operators”The editor shows the available functions. The most useful for payroll are:
- Logic:
IF,AND,OR,NOT,SWITCH,CASE - Numbers:
MIN,MAX,SUM,AVG,COUNT,ROUND,ROUNDUP,ROUNDDOWN,ABS,GETNUM - Lists:
FILTER,MAP,ALL,ANY,PLUCK - Comparison:
<,>,<=,>=,=
Use a period for decimals (119.21) and write percentages as decimals: 4.83% is written 0.0483.
Examples
Section titled “Examples”These examples come from agricultural payrolls in Guatemala. Amounts and rates are examples only: confirm current values with your accountant before using them.
Incentive bonus (Decree 37-2001) per half-month payroll period
Section titled “Incentive bonus (Decree 37-2001) per half-month payroll period”Pays Q8.33 per day attended, rounded up, with a maximum of Q125 per half-month payroll period. Asistencia is an earlier component equal to attendedDays.
MIN(ROUNDUP(8.333333333333333 * Asistencia, 0), 125)Additional piecework bonus
Section titled “Additional piecework bonus”Pays the difference when piecework earnings plus overtime exceed the guaranteed wage (Valor_trabajo). If they don’t, it pays zero.
IF((SUM(pieceworkWages) - Valor_trabajo) + overtimePay <= 0, 0, (SUM(pieceworkWages) - Valor_trabajo) + overtimePay)Days worked
Section titled “Days worked”Counts the days on which the employee had a day-wage payment greater than zero.
COUNT(FILTER(dailyWageList, x, x > 0))Employee social security (IGSS)
Section titled “Employee social security (IGSS)”Applies the employee contribution to the earnings it covers.
(Vtrabajo + SeptPlanilla + Asuetoplanilla) * 0.0483Practice with the calculator
Section titled “Practice with the calculator”Enter an employee’s days, wage and piece-rate earnings to see their totals with the formulas in this guide. To test your own formulas, open Try your own formulas: the result updates instantly and, if there is an error, it explains how to fix it.
The interactive calculator is available in the web version of this guide.
Test before completing
Section titled “Test before completing”- Create the payroll entry in Draft status and click Generate Payroll.
- Find your example employee and compare each component with the result you expected.
- To review many employees, export the entry (Payroll Entries → Export) and compare it in Excel.
- Fix the formula, generate again, and repeat until everything matches.
- Check the entry’s name too: a completed entry can no longer be renamed.
- Only then click Complete Payroll Entry. Fixing a completed entry means reverting it, which requires permissions and leaves it in Reverted status.
Common errors
Section titled “Common errors”| What happens | Cause | Fix |
|---|---|---|
| Syntax error in a comparison | =< or => was typed. |
Type <= and >=. |
| “If has too few operands” | An IF is missing one of its three parts, or test text was left inside the formula. |
Always use IF(condition, value if true, value if false) and delete any text that isn’t part of the calculation. |
| “Too many closing parentheses” | A parenthesis was closed too early, for example ROUNDUP(x), 0). |
Count the parentheses: ROUNDUP(x, 0). |
| A variable or abbreviation isn’t recognized | It is misspelled or doesn’t exist in that structure. | Copy it from the Available variables panel or the component list. |
| The result is negative | The rule doesn’t cover a case, for example an employee with few days. | Don’t fix it with ABS() alone: it flips the sign and affects every component that uses that result. Use MAX(..., 0) only if the rule really is “never less than zero.” Otherwise, use your example to decide what should be paid in that case and adjust the formula. |
If you have a question this guide does not answer, contact us in the Aragro chat or write to [email protected].