0% found this document useful (0 votes)
2 views

Cee3804_databases_2015 (1)

The document outlines the course CEE 3804: Computer Applications, focusing on Excel database functions and pivot tables. It covers database functions such as DAVERAGE and DCOUNT, and provides examples of how to use these functions with car data. Additionally, it explains the creation and customization of pivot tables for data analysis, including adding filters and charts.

Uploaded by

rahmanurannisa24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Cee3804_databases_2015 (1)

The document outlines the course CEE 3804: Computer Applications, focusing on Excel database functions and pivot tables. It covers database functions such as DAVERAGE and DCOUNT, and provides examples of how to use these functions with car data. Additionally, it explains the creation and customization of pivot tables for data analysis, including adding filters and charts.

Uploaded by

rahmanurannisa24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

CEE 3804: Computer Applications

Excel Database Functions and


Pivot Tables

Dr. Antonio Trani


Professor
Civil and Environmental Engineering
Virginia Tech
1. Topics to be Covered

❚ Database functions
❚ Pivot tables:
❘ Basics
❘ Pivot table reports

Spring 2015
CEE 3804 Slide 2
Database Functions
a. Overview

❚ Functions that provide pivot table functionality


❚ Dfunction(database,field,criteria):
❘ database:
• range of cells that make up the data
❘ field:
• name of field to perform operation
❘ criteria:
• range of cells that hold the criteria you want to hold with

Spring 2015
CEE 3804 Slide 3
Database Functions
b. List of Functions

❚ The list functions include the following:


❘ DAVERAGE(), DCOUNT(), DCOUNTA(), DGET(),
DMAX(), DMIN(), DPRODUCT(), DSTDDEV(),
DSTDDEVP(), DSUM(), DVAR(), and DVARP().
❘ Where:
• DCOUNTA(): Returns the count of nonblank records
• DGET(): Returns the value of a specified field for a single
matching record

❚ Example:
❘ Use the Cardata file on the course notes

Spring 2015
CEE 3804 Slide 4
Database Example (Cardata.xls)
The syllabus has a file with car data. Name the file Cardata.xls

Spring 2015
CEE 3804 Slide 5
Database Example (Cardata.xls)

❚ Create a separate section in the worksheet


where the query will be done
❚ Copy the sequence of titles to help you guide
the query (see below)

Spring 2015
CEE 3804 Slide 6
Database Example (Cardata.xls)

❚ Suppose we want to count the number of


cars whose weight > 3000 lbs
❚ Dcount(A1:H117,”Weight”,J6:Q7)

Database range Database field Criteria

Spring 2015
CEE 3804 Slide 7
Database Example (Cardata.xls)

❚ Read the solution from the cell containing the


database query
❚ Note that 50 cars weigh more than 3,000 lbs

Spring 2015
CEE 3804 Slide 8
Database Example (Cardata.xls)

❚ A variation to specify the database field


❚ Dcount(A1:H117,4,J6:Q7)

Criteria
Database field
Database range
Column format

Spring 2015
CEE 3804 Slide 9
Database Example (Cardata.xls)

❚ A variation to specify the database range


❚ Dcount(Cars,4,J6:Q7)

Database range Database field Criteria


Variable format Column format

Spring 2015
CEE 3804 Slide 10
Database Example (Cardata.xls)

❚ Count the number of cars made in Japan


whose weight > 2,700 lbs
❚ Verify using the regular filters in Excel or a
“Countif” statement

❚ Give it a try

Spring 2015
CEE 3804 Slide 11
Database Example (Cardata.xls)

❚ Count the number of Sporty cars whose


horsepower falls between 150 and 200 HP
❚ This requires two sets of conditions for one
variable (Horsepower)

Spring 2015
CEE 3804 Slide 12
Pivot Tables
a. Overview

❚ A Pivot Table is a powerful data-analysis tool


that Excel offers flexibility to summarize
results quickly
❚ Pivot Tables summarize data in several fields:
❘ data field
❘ row field
❘ column field

Spring 2015
CEE 3804 Slide 13
Pivot Tables
b. Demonstration Example
Region Quarter Sales Rep Sales
East 1st A 192,345
West 1st B 210,880

Regular table
East 1st C 185,223
South 1st D 165,778
Midwest 1st E 155,557
South 1st F 180,567
West 1st G 200,767
Midwest 1st H 165,663
East 2nd A 173,493
West 2nd B 200,203
East 2nd C 170,213
South 2nd D 155,339 Sales Rep (All)
Midwest 2nd E 148,990
South 2nd F 175,660 Sum of Sales Quarter
West 2nd G 190,290 Region 1st 2nd 3rd 4th Grand Total
South 2nd H 170,000
East 3rd A 145,800
East 377,568 343,706 320,800 303,955 1,346,029
West 3rd B 211,123 Midwest 321,220 148,990 147,900 150,000 768,110
East 3rd C 175,000 South 346,345 500,999 500,100 528,000 1,875,444
South 3rd D 150,000 West 411,647 390,493 400,023 370,980 1,573,143
Midwest 3rd E 147,900
Grand Total 1,456,780 1,384,188 1,368,823 1,352,935 5,562,726
South 3rd F 171,200
West 3rd G 188,900
South 3rd H 178,900
East 4th A 134,980
West
East
4th
4th
B
C
203,000
168,975
Pivot table
South 4th D 139,000
Midwest 4th E 150,000
South 4th F 200,000
West 4th G 167,980
South 4th H 189,000

Spring 2015
CEE 3804 Slide 14
Pivot Tables
c. Creating Pivot Tables

❚ There are four steps to creating a pivot table:


❘ Specify the type of source list to use for the pivot table
❘ Identify the location of the data
❘ Define row, column, values, and filters fields for the
table
❘ Select a location, name, and other options of the table
Filter Field Column Field
Sales Rep (All)

Data Field Sum of Sales Quarter


Region 1st 2nd 3rd 4th Grand Total
Row Field East 377,568 343,706 320,800 303,955 1,346,029
Midwest 321,220 148,990 147,900 150,000 768,110
Row Items South 346,345 500,999 500,100 528,000 1,875,444 Data Area
West 411,647 390,493 400,023 370,980 1,573,143
Grand Total 1,456,780 1,384,188 1,368,823 1,352,935 5,562,726

Spring 2015
CEE 3804 Slide 15
Pivot Tables
d. Data List or Table

❚ Data list/table can be:


❘ Excel list or table on a worksheet
❘ A separate database file in Access, FoxPro, etc.
❘ A collection of lists with row and column labels in one
or more worksheets
❘ Another pivot table
❚ An Excel data table must have labeled
columns

Spring 2015
CEE 3804 Slide 16
Practice File for Pivot Tables

❚ Retrieve the file called


Construction_assets_cat.xls from the web site

Spring 2015
CEE 3804 Slide 17
Excel Pivot Table Example

❚ File contains the Caterpillar vehicles owned


by a construction company
❚ Three construction sites
❚ Three types of vehicles (CAT 160H, CAT 725
and CAT 775F)
❚ Mileage, value and status (active or not) are
attributes contained in the data set

Spring 2015
CEE 3804 Slide 18
Pivot Table in Excel Ribbon (2013)

Spring 2015
CEE 3804 Slide 19
Customizing Pivot Tables
a. Specifying the Layout of a Pivot Table

❚ The PivotTable toolbar simplifies the


customizing of the pivot table:
❘ enable/disable element selection
❘ change row/column/page/data

Pivot Table Fields

Areas to Build
Pivot Table
Spring 2015
CEE 3804 Slide 20
Building the Pivot Table (Excel 2013)
❚ Start by selecting from the Pivot Table fields
Adding a data field
Starts the process

Pivot Table is
Built in the same
Spreadsheet

Construction Site
Variable gets added
To Row Pivot Area
Spring 2015
CEE 3804 Slide 21
Building the Pivot Table (Excel 2013)
❚ Adding more variables starts making the Pivot Table
more useful Adding a second
data field (Vehicle)

A second set of rows


Is added to existing
ones

Vehicle is added
to the Area
Spring 2015
CEE 3804 Slide 22
Building the Pivot Table (Excel 2013)

❚ Adding a
numeric Adding a numeric
data field (Miles)
variable
summarizes
the data
based on the
Values field Vehicle is added
to the Area

Spring 2015
CEE 3804 Slide 23
Building the Pivot Table (Excel 2013)

❚ You can
change
the
summary
in the
Value
area
Change the Sum of Miles
To Average Miles

Spring 2015
CEE 3804 Slide 24
Customizing Pivot Tables
d. Changing Excel’s Value/Data Field Summary

❚ Eleven summary functions:


• Sum: totals the values
• Count: Counts the values
• Average: Computes the average
• Max: Computes the largest value
• Min: Returns the smallest value
• Product: Computes the product of the values
• Count Nums: Counts the number of numeric data
• StdDev: Computes the standard deviation of the data
• StdDevp: Computes the standard deviation for a population
• Var and Varp: Computes the variance
Spring 2015
CEE 3804 Slide 25
Customizing Pivot Tables
b. Changing Fields (Use your Imagination)

Sales Rep (All)

Sum of Sales Quarter

Option 1:
Region 1st 2nd 3rd 4th Grand Total
East 377,568 343,706 320,800 303,955 1,346,029
Midwest 321,220 148,990 147,900 150,000 768,110
South 346,345 500,999 500,100 528,000 1,875,444
West 411,647 390,493 400,023 370,980 1,573,143
Grand Total 1,456,780 1,384,188 1,368,823 1,352,935 5,562,726

Sum of Sales Quarter


Region Sales Rep 1st 2nd 3rd 4th Grand Total
East A 192,345 173,493 145,800 134,980 646,618
C 185,223 170,213 175,000 168,975 699,411
East Total 377,568 343,706 320,800 303,955 1,346,029
Midwest E 155,557 148,990 147,900 150,000 602,447

Option 2:
H 165,663 165,663
Midwest Total 321,220 148,990 147,900 150,000 768,110
South D 165,778 155,339 150,000 139,000 610,117
F 180,567 175,660 171,200 200,000 727,427
H 170,000 178,900 189,000 537,900
South Total 346,345 500,999 500,100 528,000 1,875,444
West B 210,880 200,203 211,123 203,000 825,206
G 200,767 190,290 188,900 167,980 747,937
West Total 411,647 390,493 400,023 370,980 1,573,143
Grand Total 1,456,780 1,384,188 1,368,823 1,352,935 5,562,726

Spring 2015
CEE 3804 Slide 26
Customizing Pivot Tables
c. Adding Filters
Adding the Status Variable
❚ Adding To be used as filter
categorical
fields (non-
numeric) to the
Filter area
allows you to
execute quick
filters
Apply the filter
using this pull Categorical fields
down menu Are good filters

Spring 2015
CEE 3804 Slide 27
Customizing Pivot Tables
c. Adding Filters

❚ Adding
categorical
fields (non-
numeric) to the
Filter area
allows you to
execute quick
filters
Selected “Active”
Vehicles Status field is
Used as filter

Spring 2015
CEE 3804 Slide 28
Customizing Pivot Tables
c. Adding Pivot Charts

❚ You can also build Pivot Tables and Pivot Charts at the
same time (Windows version of Excel)

Spring 2015
CEE 3804 Slide 29
Customizing Pivot Tables
c. Adding Pivot Charts

❚ Building Pivot Tables and Pivot Charts in one step


❚ Select the icon in the Insert Tab

❚ The following steps are the same as those used to create a


Pivot Table
Spring 2015
CEE 3804 Slide 30
Customizing Pivot Tables
c. Filtering on the Fly in Pivot Charts

❚ You can apply filters to Pivot Charts

Filter leaves out


Cat 775F vehicles
Spring 2015
CEE 3804 Slide 31
Customizing Pivot Tables
e. Calculation Types

❚ Excel can perform a number of calculations:


❘ Difference from, % Of, % Difference From, Running
Total in, % of row, % of column, % of total, Index

Percent Difference from East Region Percent of Row


Sales Rep (All) Sales Rep (All)

Sum of Sales Quarter Sum of Sales Quarter


Region 1st 2nd 3rd 4th Grand Total Region 1st 2nd 3rd 4th Grand Total
East East 28.05% 25.53% 23.83% 22.58% 100.00%
Midwest -14.92% -56.65% -53.90% -50.65% -42.94% Midwest 41.82% 19.40% 19.26% 19.53% 100.00%
South -8.27% 45.76% 55.89% 73.71% 39.33% South 18.47% 26.71% 26.67% 28.15% 100.00%
West 9.03% 13.61% 24.70% 22.05% 16.87% West 26.17% 24.82% 25.43% 23.58% 100.00%
Grand Total Grand Total 26.19% 24.88% 24.61% 24.32% 100.00%

Spring 2015
CEE 3804 Slide 32
Pivot Tables in Excel 2011 for Mac

❚ Look under Insert pull-down menu

Pivot Table information

Spring 2015
CEE 3804 Slide 33
Pivot Tables in Excel 2011 for Mac (2)

❚ Create a pivot table manually

Specify the data range


For Pivot Table

Specify the location of


The new Pivot Table
(new worksheet shown)
Spring 2015
CEE 3804 Slide 34
Pivot Tables in Excel 2011 for Mac (3)

❚ Complete the Pivot Table


Specify the operation
To display totals of
Numeric field names

Specify the reporting


Filter used in the Pivot Table

Spring 2015
CEE 3804 Slide 35
Pivot Tables in Excel 2011 for Mac (4)

❚ Try other variations of the Pivot Table


The vehicle and status
Variables are rows in this
Pivot Table

Spring 2015
CEE 3804 Slide 36
Pivot Tables in Excel 2011 for Mac (4)

❚ Add a graphical
depiction to the
Pivot Table
❚ Plot is done
manually on the
Mac

Spring 2015
CEE 3804 Slide 37
Pivot Tables in Excel 2010

❚ Look under Insert pull-down menu

Pivot Table information

Spring 2015
CEE 3804 Slide 38
Example in Excel 2010

❚ Retrieve the file called


Construction_assets_cat.xls from the web site

Spring 2015
CEE 3804 Slide 39
Creating Pivot Table (Excel 2007/2010)

Spring 2015
CEE 3804 Slide 40
Creating Pivot Table (Excel 2007/2010)

Pivot Table
Builder Panel

Spring 2015
CEE 3804 Slide 41
Adding Elements to the Pivot Table
(Excel 2007)

Spring 2015
CEE 3804 Slide 42
Displaying Summaries in the Pivot Table
(Excel 2007/2010)

Here we display the sum of the vehicle


values for every type of vehicle and
every location

Spring 2015
CEE 3804 Slide 43
Finding the Average Value of Vehicles in
the Fleet (Excel 2007/2010)

Spring 2015
CEE 3804 Slide 44
Finding the Average Value of Vehicles
(Excel 2007/2010)

Spring 2015
CEE 3804 Slide 45
Try Other Formats of Your Own

Spring 2015
CEE 3804 Slide 46

You might also like