Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

DISC 112: Assignment 4 

(Total: 20 Marks) 
 

Follow the instructions in the given order to complete the assignment: 


1. Open the provided ‘Lab 4’ Excel workbook.  
2. Save the workbook in D Drive and name it after Assignment number and your roll
number (e.g. A4-2020-11-001). 
3. Rename the main worksheet as Group Information and enter the information for your
group as follows. 

Conditional Statements
We have dealt with several basic functions in Excel. Now we would like to think of scenarios where we
have a condition, and we want to take certain actions depending on what the final output is. For
example, I want to check if an employee was present throughout the month. If they were present for all
31 days, we want to give them a bonus, and if they were had any absences, then they wouldn’t get a
bonus. We can represent this situation with the following chart:

If attendance is Bonus If condition is True


equal to 31

Conditional Statement No Bonus If condition is False

To implement these conditions in Excel, we make sue of logical/comparison operators and built-in
functions such as IF, AND and OR.

Logical Operators

The following tables shows how you can compare different values in Excel:
IF Function

Open the “Practice” worksheet to learn the implementation of the built-in IF function. Start by typing in
=IF and note the dropdown menu. The helping guide also tells you what this function does.

Return Numbers

Once you have selected the function, it gives you another helping guide for the required arguments, as
shown below. The first argument is the conditional statement or the logical test that you want to check.
This is where you use your logical operators to compare values. Then you give it a value if the condition
is met (Value if True), and a value if the condition is not met (Value if False).
Here, we are comparing the value in cell A1, to see if it is equal to 2. If the value is equal to 2, we want to
return 1 and if it doesn’t, we want to return 0.

The above statement should result in a 1, indicating that A1 is equal to 2. You can change the value in A1
and see what your function returns then. You have implemented your first IF function!

You can play around with the logical operators to implement other equations. Following is a new
example. This should return 0 as the value in A1 is not less than 2.

You can try out the following use cases to understand how the function works:

So far, we have returned numbers (1 and 0) for our Value if true and value if False options. Numbers
don’t have to be limited to these. You can return any number based on your use case. We can also try
some other options:

Return TRUE/FALSE
The values TRUE and FALSE and built-in Excel values. Notice that you get a dropdown menu when you
type them in. Finish the function as shown below:

Return Words/Phrases

You can also return any word. IN the following example, we chose “Yes” and “No”. These can be any
words. In business scenarios, they will mostly be some actionable words like “Order Pending”, “Order
Complete” or “Absent”, “Present”, etc.

Note that words are always given with inverted commas. Otherwise, Excel doesn’t understand that you
are passing a string data type.

Nested IF Statements

While two resulting options are great for a conditional statement, in real life scenarios, we usually have
more than two categories. To implement that, we would nest our IF statements (one statement within
another).

Bonus If condition is True


If attendance is
equal to 31

If condition is False
Conditional
Statement Half Bonus True
If attendance is
greater than 25

No Bonus False
Conditional Statement
The example above shows a scenario with 3 possible outcomes. If the attendance is equal to 31, the
employee gets a bonus. If not, there is another IF statement asking if the employee had attendance
greater than 25; if yes, then they get a half-bonus, otherwise they get no bonus.

You can have multiple outcome values by nesting IF functions like this.

AND/OR Functions

In some scenarios, one condition may involve multiple criteria. Again, let’s build on the employee bonus
example to understand this.

Now we are giving out bonuses based on attendance and employee type. If the employee is permanent
and has been present throughout, we give out a bonus. In this case, we have 2 conditions, and we only
want to give out a bonus when both of them are met. This is where we join our conditions with an
“AND”.

In another scenario, we say that to get a bonus, the employee should either have perfect attendance, or
have a perfect customer service rating. Even if one of these conditions is true, the employee gets a
bonus. In this case, our conditions are joined by an “OR”.

Complicated scenarios can include multiple conditions, some of which can be joined by AND and others
by OR depending on the use case. The truth tables for AND and OR functions are given below as a
shortcut for your reference:

Let’s look at an example to implement AND within an IF statement. Start out with an IF function. For the
first argument where you give the conditional statements, you will write AND. Once you select the AND
function, the function helper guide below shows you the arguments required. In this case, you provide
all the conditional statements which have to be joined with the AND logic. In the example below we
have 2 conditions separated by a comma. Both of these need to be True for the IF statement to evaluate
as True.

Once you close the brackets for the AND function, note the helper guide below indicates that you have
moved back to your IF function and need to provide the value if true and false respectively.

Since numbers 1 and 2 satisfy our conditions, we evaluate to TRUE. You can try changing the value in A1
to test other scenarios.

The syntax for implementing OR is the same as we just implemented OR.

TASK 1 (10 Marks)


Have a look at the worksheet “Trips”. You have information for students who have registered to go to
trips to certain locations. Details regarding their ticket purchases are given as well.

You need to recode the following data using the additional information worksheet:

 Ticket type (column C) – to be recoded in column H


o If the type is Early bird, you recode it as 1, if the type is Standard, you recode it as 2 and
so on (refer to the key given in additional information worksheet)
 Location (column B) – to be recoded in column I
o If the Location is Arang Khel, then you should recode it as 1, if the location is Skardu, you
should recode it as 2 and so on (additional information worksheet).

An example of the solution is shown below:


Your solution should include cell referencing (do not copy the keys to the main worksheet, instead
refer to the values in the additional information worksheet).

TASK 2 (3 Marks)
Trips to two locations have been cancelled. These locations are given on the additional information
worksheet. Using this, indicate on the “Trips” worksheet if the student is eligible for a refund in column
G. Those getting a refund should have a Yes written against them, otherwise write a No.

An example of the solution is given below:

Your solution should include cell referencing (do not copy the criteria to the main worksheet, instead
refer to the values in the additional information worksheet).

TASK 3 (3 Marks)
Customers need to be assigned the following categories based on their purchase pattern:

 High Value
 Average
 Low Value

The criteria is given in the additional information worksheet.

An example of the solution is given below:


Your solution should include cell referencing (do not copy the final values to the main worksheet,
instead refer to the values in the additional information worksheet).

TASK 4 (4 Marks)
The students can win a prize by entering a lucky draw if they have purchased tickets worth 20,000 or
more. Eligibility is limited to premium and standard ticket types only. Populate column K with “eligible”
and “not eligible” against each row to decide which students can participate in the lucky draw.

You might also like