If-Else Statements in OpenOffice Calc

Status
Not open for further replies.

Osiris

Golden Master
Messages
36,817
Location
Kentucky
If-Else Statements in OpenOffice Calc

I do a lot with spreadsheets. And when I work in spreadsheets I work in OpenOffice. Most people know the ins and outs of spreadsheets, but many don't realize just how powerful spreadsheets can be. Openoffice Calc holds a lot more bang for the users' buck than you might think. For instance, did you know that Calc can do If/Else statements? In this spreadsheet tutorial you will learn how to use IF/ELSE statements in OpenOffice Calc.
Let's say you have two columns of numbers and you want to add a third column based on the other two data. That third columns' entry will depend upon the information in the first two. IF entry A is greater than B THEN C is X ELSE C is Y.
But how does one do this? It's actually quite easy. Let's start out with a more simple example and move on to a more complex example.
The first example will illustrate a basic IF/ELSE statement that uses only two columns of data. We'll do a simple spreadsheet that deals with how many persons each employee will bring to a company picnic. To make things easy if the person enters “0″ that means they are not bringing a guest (the employee, however, IS required to come) and if they enter “1″ that means they are which means that employee equals two attendees. The first column will represent the name of the employee and the second column is how many guests the employee will bring. The formula to enter into the third column would look like:
=IF(B1=1;2;1)
What this will do is enter a “2″ in the third cell is the employee is bringing a guest and a 1 if they are not.
Now let's make this a bit more complex. For this example we'll have three columns. The first column is a number that represents how many hours an employee worked. The second column will represent how many hours over 40 they worked. The third column will represent how much overtime pay they made. But let's say you also have to account for zero hours worked. The formula for the second column would look like this:
=IF(A9<=40;0; IF(A9>40;(A9-40)))
For the third column let's continue with this idea. Say if an employee worked over 5 hours of overtime they would gain an extra 100 dollar bonus in their check. So we'll add a fourth column for bonuses. For simplicity's sake all employees make $10.00 an hour. Overtime is standard time and a half pay. So the forumla for the third column would be a standard:
=SUM((40*10)+(B9*15))
And the formula for the fourth column would be:
=IF(B9>=5;100;0)
Now for the final total for employee salary a fifth column would be added that would look like:
=SUM(C9+D9)
Final Thoughts
The examples may be very simple but the idea can be applied to many instances. Using IF/ElSE statements in OpenOffice Calc can quickly take your spreadsheets to a much higher level of usability.
 
Status
Not open for further replies.
Back
Top Bottom