Chapter 11: Practical Example - Writing a Payroll Fast Formula
Objective of This Chapter
In this chapter, you will learn how to create a simple payroll Fast Formula by applying the concepts of variables, conditions, and calculations practically.
Scenario
We want to create a formula to calculate the monthly bonus based on the following rules:
-
If the employee salary is greater than 50000, bonus is 10% of salary.
-
If the employee salary is less than or equal to 50000, bonus is 5% of salary.
-
If the employee is a new joiner (less than 6 months), bonus is fixed at 2000.
Step-by-Step Formula
-
Inputs
We need two inputs:
-
SALARY
-
MONTHS_WORKED
-
Declare Bonus Variable
-
Apply Logic for New Joiners
-
Apply Logic for Other Employees
-
Return the Bonus
Full Formula Example
Testing Example
SALARY | MONTHS_WORKED | BONUS |
---|---|---|
60000 | 8 | 6000 |
45000 | 8 | 2250 |
50000 | 3 | 2000 |
Best Practices Applied
✅ Clear input definitions
✅ Defaults provided
✅ Conditions clearly structured
✅ Easy to maintain and update
✅ Proper RETURN statement
Mini Practice Quiz
-
What bonus does a new joiner get?
Answer: 2000 -
How is the bonus calculated if salary is above 50000?
Answer: 10% of salary -
What happens if
SALARY
is missing in input?
Answer: Default value 0 is used.
No comments:
Post a Comment