23
1 Managing Excel Databases Validating Data Entry Filtering a Database (Using the AutoFilter and the Advanced Filter Commands) Using Functions to Extract Details from a List (Database Statistical Functions)

CURS7 - Excel Databases

Embed Size (px)

DESCRIPTION

CURS7 - Excel Databases

Citation preview

Page 1: CURS7 - Excel Databases

1

Managing Excel Databases

Validating Data Entry

Filtering a Database (Using the AutoFilter

and the Advanced Filter Commands)

Using Functions to Extract Details from a

List (Database Statistical Functions)

Page 2: CURS7 - Excel Databases

2

Excel Databases. Validating Data Entry

Validation represents a procedure that allows the verification to

the correctness of data entry into the cells. This procedure is

operational for any worksheet cell that contains values edited by

the user. Through validation data entry one restrict the entries

into the cells according to a given criteria at which the worksheet

values, entered by the user, must to respond.

An important aspect concerning this facility of databases

exploitation is that the validation is not operational at all as

concerns an Excel formula because one considers that any

formula returns automatically the correct results.

In fact, the validation of data entry presumes the following steps:

Select the range of cells where you want the validation to apply;

Choose Validation command from the Data menu – Excel will

display the Data Validation dialog box.

Page 3: CURS7 - Excel Databases

3

Validating Data Entry Specifying Data Type and Acceptable Values

Page 4: CURS7 - Excel Databases

4

In Data Validation dialog box we choose firstly the Settings tab

that allows us to set up the validation rules for the selected cells.

To specify the kind of data we’ll allow, we must open the Allow

list from where we can choose one of the following data type:

Whole number, Decimal number, List, Date an Time, Text length

and Custom. Initially, Excel allows us to enter into its worksheet

cells any kind of data, and that because the default option from

this list is actually “Any value”, so, the data entries are made

without any restrictions.

The dialog box has also a second drop-down list that contains all

the comparison operators (between, not between, equal to and

the like). After we choose the suitable operator, Excel modifies

the informational structure of the dialog box, so that we can enter

all the additional information about the chosen type.

For example, if we choose the Whole number option and

Between operator, the dialog box will specify both a minimum

and maximum acceptable value.

Page 5: CURS7 - Excel Databases

5

Validating Data Entry Specifying Data Type and Acceptable Value

The range “Personal Numeric Code” will be validated so

that to admit only a number with 13 digits.

Page 6: CURS7 - Excel Databases

6

Validating Data Entry

Specifying an Input Message

Page 7: CURS7 - Excel Databases

7

To supply an input prompt to guide us when we are entering a data

into the current cell, we simply click the Input Message tab in the

Data Validation dialog box.

Through this facility we have the opportunity to specify both the

content of the custom message and the title of the text box in

which it’s displayed our message. The title automatically formatted

using the bold characters.

This user’s custom message will be displayed as a comment

beside the validated cell whenever the user selects that cell.

So, that prompt will appear whenever the validated cell is active.

For example, we can have a prompt which specifies that the cell

requires an integer number with 13 digits.

By choosing Data Validation we can create such an input

message, even without creating a validation rule, in other words,

without forcing the user to enter a particular kinds of values.

Page 8: CURS7 - Excel Databases

8

Validating Data Entry Specifying Error Alert Style and Message

Page 9: CURS7 - Excel Databases

9

Validating Data Entry Specifying Error Alert Style and Message

Page 10: CURS7 - Excel Databases

10

If we somehow elude the validation rule when we are entering a

data into the current cell, Excel will display a standard error

message pointing out that the value we entered into that cell is

not a valid one.

Through a dialog box, Excel actually forces the user either to retry

the entry using a correct value this time, or to cancel the action

and leaves this way the previous value in place (or leaves the

cell empty).

If we want to set up a custom error message when the entry is

invalid we have to use the third tab, that is the Error Alert tab.

Through this facility one can establish:

1. First of all the window title

2. Then the proper error message of the user

3. And, finally, we choose the style of message that appears

when the user doesn’t respect the validation rule.

Page 11: CURS7 - Excel Databases

11

These three message styles display different icons in the dialog

box and also they have different consequences for the user during

an invalid entry.

If our message style is Stop (actually the default option), the user

is practically forced to Retry or even to Cancel the action.

If we choose the option Warning the entry is invalid but however

the user have a chance to leave the wrong value into the current

cell simply by choosing the answer Yes. The button No allows to

reenter an other value that could be a correct one.

If we choose Information the user will be told about the produced

error, but will not be given a retry option (we can only to accept

the invalid value through Ok or even to Cancel the action).

Page 12: CURS7 - Excel Databases

12

Validating Data Entry. Examples

The list of data types that appears on the Settings tab doesn’t

include a Text type. How can we force a text entry into the cells of

the Excel worksheet?

Taking into account that the Text Length option doesn’t create a

requirement for a text entry, however, to require text, we must

choose the Custom option that allow to type in the custom formula,

actually, the address of the selected cell (B3 in this instance).

Page 13: CURS7 - Excel Databases

13

Filtering a Database

To filter a worksheet database means to hide all the

database records, except those that satisfy the conditions

specified into a criteria range.

From the complexity criteria standpoint, Excel provides

two filtering commands:

AutoFilter for simple criteria;

Advanced Filter for more complex criteria and also

to extract a subset of our database to another

location of the worksheet.

Page 14: CURS7 - Excel Databases

14

Filtering a Database. AutoFilter command

Page 15: CURS7 - Excel Databases

15

Filtering a Database. AutoFilter command

Page 16: CURS7 - Excel Databases

16

Suppose that we have a database which manage the employees’

informational structure, comprising the fields: Personal Numeric

Code, Employee’s name, Department and the other heading labels.

Starting from this initial structure we intend to filter this database,

using the AutoFilter facility, with the purpose to extract only those

database records in which the employees’ department is IT.

To use the AutoFilter command, firstly we select any cell in the

database, then we choose from the Data menu, the Filter

command and, after that, the AutoFilter option.

Excel will display drop-down arrows next to each of the column

headings of our database. Next, we can simply click the arrow of

the department heading to reveal the list that contains all the

departments, as unique values. From this list we select the IT

department that represents in fact the filtering criteria.

As result, Excel will display a restricted structure of the database

that comprises only the records which meet the specified criteria,

hiding actually the other records (the other rows of the table).

Page 17: CURS7 - Excel Databases

17

Filtering a Database. AutoFilter command

Page 18: CURS7 - Excel Databases

18

We can also define a requirement that presumes two selecting

conditions. Suppose, for instance, that we want to display a list

containing all the employees which are working on in IT and

Creditare company’s departments.

To specify more criteria to a single column (Department) we have

to use the Custom option from the drop-down list of that field.

In the Custom AutoFilter dialog box one can specify two

conditions, using two possible logical operators which are And,Or.

The list boxes on the left side of the dialog box provide a selection

of relationships (Equals, Does Not Equal, Is Greater Than and so

on), and the list boxes on the right side allow us to select the

values that appear in Department column.

The resulting list will contain only the records that meet the

specified criteria, hiding the other ones.

Page 19: CURS7 - Excel Databases

19

In contrast to the AutoFilter command, the Advanced Filter

command allows to do the following:

Specify criteria involving two or even more columns and the

logical operators;

Specify three or more criteria for a particular column, where at

least one OR logical operator is involved;

Specify computed criteria where we can enter an Excel function.

In addition, the Advanced Filter command can be used to extract

the records from the database, placing copies of those records in

another location of the current worksheet.

To filter a database using this facility we must choose the

Advanced Filter option, from the Filter command list, from the

Data menu.

Using the ADVANCED FILTER Command

Page 20: CURS7 - Excel Databases

20

Using the ADVANCED FILTER Command

Database

address

Criteria

range

Possibilities

for displaying

the filter

results

Resulting

range

Displaying

records with

unique value

Page 21: CURS7 - Excel Databases

21

Database Functions

General Syntax:

=function_name(database;field;criteria)

DSUM

DPRODUCT

DMIN

DMAX

DAVERAGE

DCOUNT(A)

DGET

Page 22: CURS7 - Excel Databases

22

The Database statistical functions represents in fact counterparts

of the well-known mathematical and statistical functions (SUM,

PRODUCT, COUNT, MIN, MAX, AVERAGE), excepting the

function DGET which has not a corresponding function.

The difference between these database functions and their

counterparts is that the formers operate only for the database

records that match the conditions specified in the criteria range.

DSUM adds the values

DPRODUCT multiplies the values

DMIN returns the smallest number

DMAX returns the largest number

DAVERAGE calculates the average value

DCOUNT and DCOUNTA counts the cells that contain either only

numbers (DCOUNT), or any kind of data (DCOUNTA)

Page 23: CURS7 - Excel Databases

23

All these functions execute some calculations, but only

for those records of a database that perfectly match

with the given conditions.

DGET extracts an information from a database, the information

that satisfies the required condition specified into criteria range.

What means the database functions arguments:

Database – represent either the address of the worksheet

database which contains in the first row the database labels, or a

range name of the database;

Field – indicates which database column is used in the function

for the wished calculation operation (either using the column

label, or using the number of the column within the database);

Criteria – represents a range of cells that contains the condition

or the conditions that must be satisfied.