Excel handout - Department of Computer Science

advertisement
Faculty of Arts & Sciences
Department of Computer Science
December 1, 2012
Working with MS-Excel 2010
Excel is a program that allows us to create different workbooks formed of different worksheets. It is very
useful in conducting calculations, data analysis, statistics… Each worksheet is formed of a grid of cells
where the information (data, functions, formulas) will be stored. Each cell is referenced by a column
number and a row number (C3). You can add, delete, rename, and move worksheets in a workbook.
Rows and columns can be also added, deleted, hidden…
The file “Students Datalist.xlsx” is an excel worksheet that encloses a list of students for a high school
class. The students are distributed among two different sections (1 and 2). The school year is formed of
three different terms. In each term, the students will have a quiz and an exam. Then, the average of
each term is calculated as follows:
Term average = 40% * quiz grade + 60% * exam grade
At the end of the year, the final grade for each student is calculated as follows:
Final grade = 25% * term 1 average + 25% * term 2 average + 50% * term 3 average
Exercise one: Functions
To start with, open the file “Students Datalist.xlsx”. Open the sheet named: “Functions”. The aim of this
exercise is to use functions and formulas to perform some grades calculations and statistics.MS-Excel
contains different built-in functions categorized into different groups: (Financial, Date and Time, Math,
Statistical, Lookup & Reference, Text …). In addition, you can write and use your own formulas.
When inserting a function or a formula in a cell, it should always start with the “=” sign so not to be
treated as a text.
The column F should display the average grade for each student for the first term.
1. Insert in cell F4 the formula responsible of calculating the average for the student: “Mila
Counter”.
Faculty of Arts & Sciences
Department of Computer Science
December 1, 2012
-
In cell F4, type in the following formula: = 0.4 * D4 + 0.6 * E4
To round the value to its nearest integer, the excel offers a function called: Round. Round takes
as argument the value that should be rounded and the number of decimal places to reduce the
number to.
-
Update the formula in cell F4 to the following: = round(0.4 * D4 + 0.6 * E4, 0)
-
To copy the formula to all other students, just drag it down.
You need to add the same formula to calculate the term 2 average (column I) and term 3 average
(column L). Instead of rewriting it, you can copy it from the column F.
2. Copy the formula from cell F4 to cell I4.
-
Select cell F4. From the Home tab, select Copy
-
Select cell I4. From the Home tab, select Paste -> Formulas
-
Now drag the formula to all other students in column I.
As you noticed, when copying the formula, automatically the cells used are changed accordingly.
3. Repeat the same steps to copy the formula to column L also.
4. In cell M4, insert a formula to calculate the final grade for student: “Mila Counter”
-
In cell M4, type in the following formula: =ROUND(0.25*F4 + 0.25*I4 + 0.5*L4, 0)
-
Drag the formula to all other students
Now, we need to perform some statistics about the grades for all quizzes and exams (average, minimum
grade, maximum grade, and the median) as shown below. Fortunately, MS-Excel provides built-in
functions for this purpose.
5. In cell D42, insert a function to calculate the average for all students’ grades for quiz 1.
Faculty of Arts & Sciences
Department of Computer Science
December 1, 2012
-
Select cell D42
-
From the formulas tab, choose Insert function
-
Select a category: statistical
-
Select a function: Average
-
In Number1: specify the range of cells: D4:D40
-
Or instead, you can directly insert in cell D42 the following function: = average(D4:D40)
-
Drag the function horizontally until the final grade column
6. In cell D43, insert a function to calculate the minimum grade in quiz 1
-
In cell D43, insert the following function: =min(D4:D40)
-
Drag it horizontally up to the final grade column
7. In cell D44, insert a function to calculate the maximum grade in quiz 1
-
In cell D44, insert the following function: =max (D4:D40)
-
Drag it horizontally up to the final grade column
8. In cell D45, insert a function to calculate the median grade in quiz 1
-
In cell D45, insert the following function: =median(D4:D40)
-
Drag it horizontally up to the final grade column
MS-Excel offers more advanced functions to calculate different types of statistics. Some of these
functions are: Count, Countif, Countifs, Averageif, Averageifs, Sumif, Sumifs, …

Count: count the number of cells containing numbers in a specified range of cells.

Countif(range, criteria): count the number of cells meeting a certain criteria in a
specified range

Countifs(range1, criteria1, range2, criteria2…): more than one criteria to met

Averageif(range, criteria, average_range): calculates the average of values in a range,
that meet the specified criteria
Faculty of Arts & Sciences
Department of Computer Science
December 1, 2012

Averageifs(average_rannge, range1, criteria1, range2, criteria2, …): calculates the
average of values that meet all the criteria in a specific range

Sumif and Sumifs: Calculate the sum of values meeting the criteria in a specified range

…
To apply some of these functions:
9. In cell J49, insert a function to calculate the average final grade for all females.
-
In cell J49, type in the following function: =AVERAGEIF(B4:B40,"F", M4:M40)
10. In cell J50, insert a function to calculate the average final grade for all males.
-
In cell J50, type in the following function: =AVERAGEIF(B4:B40,"M", M4:M40)
11. In cell j51, insert a function to get the number of females who got a grade above 80.
-
In cell j51, type in the following function: =COUNTIFS(B4:B40,"F", M4:M40,">80")
12. In cell j52, insert a function to get the average final grades for males of section 1.
-
In cell j52, type in the following function: =AVERAGEIFS(M4:M40,B4:B40,"M",C4:C40,"1")
13. In cell j53, insert a function to get the percentage of the final grades that are above the
average.
-
In cell j53, type in the following function: =COUNTIF(M4:M40,">" &M42)/COUNT(M4:M40)
Another type of functions offered by MS-Excel is the lookup functions. These functions are used to
locate some information inside a range of cells or a table. Some of these functions are: Index, Match,
VLookup, HLookup …

Index (array, row_num, col_num) : it returns the value of the cell at the intersection of a row
and a column.

Match(value, array, match_type): it returns the position of the value inside an array.

VLookup(value, array, col_num, type): it searches for the value in the first column of the array
and returns the value in the same row, but in the column specified by col_num.
Faculty of Arts & Sciences
Department of Computer Science
December 1, 2012

HLookup(value, array, row_num, type): it searches for the value in the first row of the array and
returns the value in the corresponding row (row_num)
For the type (in VLookup and HLookup), it can be either true or false. False means that the matching
should be an exact match and true means that the matching should be an approximate match.
14. In cell J54, insert a function to get the name of the student who got the highest final grade.
-
= INDEX(A4:A40,MATCH(M44,M4:M40,0),1)
15. In cell J55, insert a function to get the final grade for “Ruby Caine”
-
= VLOOKUP("Ruby Caines", A4:M40,13,FALSE)
The results are shown below:
16. In cell N4, insert a function to get the letter grade equivalent to the final grade based on the
table in cells: (Q7 : R11)
-
Insert a column before Q containing the lower bound of each range (0, 60, 70, 80, 90)
-
In N4, insert the following function: =VLOOKUP(M4,P$7:R$11,3,TRUE)
NB. The $ is used to fix the column number or the row number so that when the function is
dragged, it remains still.
17. In cell O4, a message should be displayed as follows:
o
If the final grade of the student is > 85 and the average grade for the final term is > 90,
the message should be: student name, Great job!!
Faculty of Arts & Sciences
Department of Computer Science
December 1, 2012
o
If only the final grade of the student is > 85, the message should be: student name, good
Job!
-
o
If the final grade is < 60, the message should be: student name, you failed!
o
No message will be output otherwise
In cell O4, insert the following function:
=IF(AND(M4>85, L4>90), A4& " , Great job", IF(M4 > 85, A4 & ", Good job",IF(M4 < 60, A4 &
" You failed", "")))
Exercise Two: Conditional Formatting + sorting + charts
The conditional formatting feature is about modifying some cells formatting based on a condition. There
are different types of conditional formatting: Highlight cells, top/bottom, Data Bars, Color Scales, Icon
Sets and we will see some of these below.
Open the sheet “Cond. Format + sort + chart” in your workbook.
1. For the column E (Semester 1 average), apply the necessary conditional formatting to highlight
the grades below the average by blue. Then apply another conditional formatting to change
the font of the highest 10 grades to red and italic.
-
Select the values in column E. From the Home tab, select Conditional Formatting -> Highlight
Cells Rules -> More Rules -> “Format only cells that are above or below the average” ->
below and then click on format and apply the filling.
-
Reselect the values in column E. Select Conditional Formatting -> Highlight Cells Rules ->
More Rules -> “Format only top or bottom ranked values” -> top 10 and format accordingly.
2. For the column F, three icons should be displayed with the grades as follows: a true mark for
the grades that are >= average + 10, an exclamation mark for the grades that are between
average – 10 and average + 10 and an X mark otherwise
-
Select the values in column F. Select Conditional Formatting -> Icon sets -> More Rules ->
Format all cells based on their values.
-
Select the appropriate icon set.
-
In Type, select formula and then in the first value, write: =average($F$4:$F$40) + 10 and in
the second value, write: =average($F$4:$F$40) – 10
Faculty of Arts & Sciences
Department of Computer Science
December 1, 2012
3. Sort the table by section ( 1, 2), and then by gender inside the same section (F, M) and then by
Name (A – Z).
-
Home tab -> Editing -> Sort & Filter -> Custom Sort -> Sort by: Section, Values: Smallest to
largest. Then Press Add Level -> Then by: Gender, Values: A to Z -> Add Level -> Then by:
Name, Values: A to Z. Press ok.
Part of the resulting table is shown below:
Charts:
Charts are graphs that present data in a visual way. These are visual representation of the worksheet
data.
There are different kinds of charts in Excel and each chart can be formatted by different layout and
different styles:
Faculty of Arts & Sciences
Department of Computer Science
December 1, 2012
4. Plot a line with markers chart that displays the final grade of all students of section 1:
-
Select the names and the grades for students of section 1
-
Insert -> Chart -> line with markers
5. Format the chart as shown below:
-
Right click on the axis to change the minimum grade to 40
-
Right click on the plot area and choose format plot area to change its filling
-
Right click on the chart area and format it to change its filling
-
Right click on the data series and add data labels that format it to change the markers fill
-
Change the position of the legend to be below the chart
Exercise Three: Filtering
Open the worksheet Filtering in your workbook.
Filtering a table data list is used to show only the data that meet some conditions. You can filter text
data or numbers. You can choose to filter data to show only top values or bottom values, or to show
values above or below the average…
Faculty of Arts & Sciences
Department of Computer Science
December 1, 2012
1. Filter the list of data to show only the students whose last name starts with a C, in Section 1
and whose final grade is above 65.
-
Home -> Sort & Filter -> Filter
Exercise Four: Formatting
You can apply different formatting to your data set to make it more organized and more attractive.
1. Format the data set as shown below in the picture.
-
Select the cells that you want to format.
Home -> Cells -> Format -> Format Cells and choose the elements that you need to change:
borders, fillings, alignment…
For the background picture, you can add a rectangle shape and change its filling to the
picture. Then set its transparency so that it doesn’t hide the data.
Download