* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Final CIS 300 Test Reviews
Survey
Document related concepts
Transcript
CIS 300 EXCEL &ACCESS AGENDA 1. Logical Functions. 2. Mathematical Functions. 3. Statistical Functions. 4. Lookup Functions. 5. Date Functions. 6. Time Functions. 7. Text Functions. 8. Database Functions. 9. Sorting data by one and multiple columns. 10. Applying auto filter on one and multiple columns. 11. Calculating subtotals. 12. Applying advanced auto filters. 13. Pivot tables and Pivot charts. 14. Insert or delete a drop down list. 15. What if analysis 16. Data Validation 17. Protecting Worksheets 18. Hiding Columns 19. Access Review. MICROSOFT EXCEL LOGICAL FUNCTIONS AND =AND(logical1, [logical2], ...) OR =OR(logical1, [logical2], ...) NOT =NOT(logical) IF =IF(logical_test, [value_if_true], [value_if_false]) NESTEDIF IF( condition1, value_if_true, IF( condition2, value_if_true, value_if_false )) IFERROR 3 =IFERROR(value, value_if_error) THE FUNCTION Syntax: =AND(logical1, [logical2], ...) Arguments: •logical1 Required The first condition that you want to test that can evaluate to either TRUE or FALSE. •logical2, ... Optional Additional conditions that you want to test that can evaluate to either TRUE or FALSE, up to a maximum of 255 conditions. Description: •Returns FALSE if one or more arguments is FALSE 4 •Otherwise, all arguments must evaluate TRUE THE FUNCTION Syntax: =OR(logical1, [logical2], ...) Arguments: •logical1 Required The first condition that you want to test that can evaluate to either TRUE or FALSE. •logical2, ... Optional Additional conditions that you want to test that can evaluate to either TRUE or FALSE, up to a maximum of 255 conditions. Description: •Returns TRUE if one or more arguments is TRUE 5 •Otherwise, all arguments must evaluate FALSE THE FUNCTION Syntax: =NOT(logical) Arguments: •logical Required A value or expression that can be evaluated to TRUE or FALSE. Description: 6 •Reverses the value of its argument. THE FUNCTION Syntax: =IF(logical_test, [value_if_true], [value_if_false]) Arguments: 7 •logical_test Required Any value or expression that can be evaluated to TRUE or FALSE. •value_if_true Optional •The value that you want to be returned if the logical_test argument evaluates to TRUE. •If logical_test evaluates to TRUE and the value_if_true argument is omitted (that is, there is only a comma following the logical_test argument), the IF function returns 0 (zero). •To display the word TRUE, use the logical value TRUE for the value_if_true argument. THE FUNCTION Description: 8 •The IF function returns one value if a condition you specify evaluates to TRUE, and another value if that condition evaluates to FALSE. NESTED IF IN EXCEL A nested IF statement says something like... "If the answer is yes, do this. If the answer is no do this or this (depending on...“ Syntax: 9 IF( condition1, value_if_true, IF( condition2, value_if_true, value_if_false )) THE FUNCTION Syntax: =IFERROR(value, value_if_error) Arguments: • Value • Value_if_error Required. The value to return if the formula evaluates to an error. The following error types are evaluated: #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, or #NULL!. Required. The argument that is checked for an error. Description: Returns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula. Use the IFERROR function to trap and handle errors in a formula. 10 • Is there an employee named Daniel Handel? (Yes or No) =IF(C1="Handel"&B1="Daniel","yes","No") Microsoft ExcelMathematical Functions SUM =SUM(number1,[number2], ...) SUMIF =SUMIF(range,criteria,[sum_range]) SUMIFS =SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...) 12 ROUND =ROUND(number,num_digits) THE FUNCTION Syntax: =SUM(number1, [number2], [number3], [number4], ...) Arguments: •number1 Required The first item that you want to add. •number2, number3, number4, ... Optional The remaining items that you want to add, up to a total of 255 items. Description: 13 •Adds all the numbers that you specify as arguments. THE FUNCTION Syntax: =SUMIF(range, criteria, [sum_range]) Arguments: •range Required The range of cells that you want evaluated by criteria. oCells in each range must be numbers or names, arrays, or references that contain numbers. oBlank and text values are ignored. criteria Required The criteria in the form of a number, expression, a cell reference, text, or a function that defines which cells will be added. oCriteria can be expressed as 32, ">32", B5, "32", "apples", or TODAY(). •sum_range Optional The actual cells to add, if you want to add cells other than those specified in the range argument. oExcel adds the cells that are specified in the range argument (the same cells to which the criteria is applied). •Sums the values in a range that meet criteria that you specify. 14 Description: THE FUNCTION Syntax: SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...) Arguments: sum_range Required. One or more cells to sum, including numbers or names, ranges, or cell references that contain numbers. Blank and text values are ignored. criteria_range1 Required. The first range in which to evaluate the associated criteria. criteria1 Required. The criteria in the form of a number, expression, cell reference, or text that define which cells in the criteria_range1 argument will be added. For example, criteria can be expressed as 32, ">32", B4, "apples", or "32." criteria_range2, criteria2, … 15 Optional. Additional ranges and their associated criteria. Up to 127 range/criteria pairs are allowed. THE FUNCTION Description: Adds the cells in a range that meet multiple criteria. For example, if you want to sum the numbers in the range A1:A20 only if the corresponding numbers in B1:B20 are greater than zero (0) and the corresponding numbers in C1:C20 are less than 10, you can use the following formula: =SUMIFS(A1:A20, B1:B20, ">0", C1:C20, "<10") 16 IMPORTANT The order of arguments differ between the SUMIFS and SUMIF functions. In particular, thesum_range argument is the first argument in SUMIFS, but it is the third argument in SUMIF. If you are copying and editing these similar functions, make sure you put the arguments in the correct order THE FUNCTION Syntax: =ROUND(number, num_digits) Arguments: •number Required The number that you want to round. •num_digits Required The number of digits to which you want to round the number argument. Description: 17 •Rounds a number to a specified number of digits. AVERAGE =AVERAGE(number1, [number2],...) AVERAGEIF =AVERAGEIF(range, criteria, [average_range]) COUNT =COUNT(value1, [value2],...) COUNTIF =AVERAGEIF(range, criteria, [average_range]) COUNTIFS COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…) COUNTA =COUNTA(value1, [value2],...) MAX =MAX(number1,[number2],...) MIN =MIN(number1,[number2],...) LARGE =LARGE(array,k) SMALL =LARGE(array,k) 18 MICROSOFT EXCEL STATISTICAL FUNCTIONS THE FUNCTION Syntax: =AVERAGE(number1, [number2],...) Arguments: •number1 Required The first number, cell reference, or range for which you want the average. •number2, ... Optional Additional numbers, cell references or ranges for which you want the average, up to a maximum of 255. Description: 19 •Returns the average (arithmetic mean) of the arguments. THE FUNCTION Syntax: =AVERAGEIF(range, criteria, [average_range]) Arguments: •range Required One or more cells to average, including numbers or names, arrays, or references that contain numbers. •criteria Required The criteria in the form of a number, expression, cell reference, or text that defines which cells are averaged. •average_range Optional The actual set of cells to average. •Returns the average (arithmetic mean) of all the cells in a range that meet a given criteria. 20 Description: THE FUNCTION Syntax: AVERAGEIFS(average_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...) Arguments: •Average_range Required. One or more cells to average, including numbers or names, arrays, or references that contain numbers. •Criteria_range1, criteria_range2, … Criteria_range1 is required, subsequent criteria_ranges are optional. 1 to 127 ranges in which to evaluate the associated criteria. •Criteria1, criteria2, ... Criteria1 is required, subsequent criteria are optional. 1 to 127 criteria in the form of a number, expression, cell reference, or text that define which cells will be averaged. For example, criteria can be expressed as 32, "32", ">32", "apples", or B4. Description: 21 •Returns the average (arithmetic mean) of all cells that meet multiple criteria. THE FUNCTION Syntax: =COUNT(value1, [value2],...) Arguments: •value1 Required The first item, cell reference, or range within which you want to count numbers. •value2, ... Optional Up to 255 additional items, cell references, or ranges within which you want to count numbers. Description: 22 •Counts the number of cells that contain numbers, and counts numbers within the list of arguments. THE FUNCTION Syntax: =COUNTIF(range, criteria) Arguments: •range Required One or more cells to count, including numbers or names, arrays, or references that contain numbers. oBlank and text values are ignored. criteria Required A number, expression, cell reference, or text string that defines which cells will be counted. oCriteria can be expressed as 32, ">32", B4, "apples", or "32". •Counts the number of cells within a range that meet a single criterion that you specify. 23 Description: THE FUNCTION Syntax: COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…) Arguments: • criteria_range1 Required. The first range in which to evaluate the associated criteria. • criteria1 Required. The criteria in the form of a number, expression, cell reference, or text that define which cells will be counted. For example, criteria can be expressed as 32, ">32", B4, "apples", or "32". • criteria_range2, criteria2, ... Optional. Additional ranges and their associated criteria. Up to 127 range/criteria pairs are allowed. IMPORTANT Each additional range must have the same number of rows and columns as the criteria_range1argument. The ranges do not have to be adjacent to each other. •Applies criteria to cells across multiple ranges and counts the number of times all criteria are met. 24 Description: THE FUNCTION Syntax: =COUNTA(value1, [value2],...) Arguments: •value1 Required The first argument representing the values that you want to count. •value2, ... Optional Additional arguments representing the values that you want to count, up to a maximum of 255 arguments. Description: 25 •Counts the number of cells that are not empty in a range. THE FUNCTION Syntax: =MAX(number1,[number2],...) Arguments: •number1, number2, ... Required 1 to 255 numbers for which you want to find the maximum value. Description: 26 •Returns the largest value in a set of values. THE FUNCTION Syntax: =MIN(number1,[number2],...) Arguments: •number1, number2, ... Required 1 to 255 numbers for which you want to find the minimum value. Description: 27 •Returns the smallest value in a set of values. THE FUNCTION Syntax: =LARGE(array,k) Arguments: •array Required The array or range of data for which you want to determine the k-th largest value. k Required The position (from the largest) in the array or cell range of data to return. Description: 28 •Returns the k-th largest value in a data set. THE FUNCTION Syntax: =SMALL(array,k) Arguments: •array Required The array or range of data for which you want to determine the k-th smallest value. k Required The position (from the smallest) in the array or cell range of data to return. Description: 29 •Returns the k-th smallest value in a data set. MICROSOFT EXCEL LOOKUP FUNCTIONS VLOOKUP =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]) HLOOKUP = HLOOKUP(lookup_value,table_array,row_index_num,range_lookup) INDEX =INDEX(array,row_num,[column_num]) MATCH 30 =MATCH(lookup_value, lookup_array, [match_type]) THE FUNCTION Syntax: =VLOOKUP(lookup_value,table_array,col_index_num,[range_lookup]) Arguments: •lookup_value Required The value to search in the first column of the table or range. •table_array Required The range of cells that contains the data. •col_index_num Required The column number in the table_array argument from which the matching value must be returned. •range_lookup Optional A logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match. •Searches the first column of a range of cells, and then returns a value from any cell on the same row of the range. 31 Description: THE FUNCTION Syntax: = HLOOKUP(lookup_value,table_array,row_index_num,range_lookup) Arguments: • Searches for a value in the top row of a table or an array of values, and then returns a value in the same column from a row you specify in the table or array. 32 •lookup_value Required The value to search in the first row of the table or range. •table_array Required The range of cells that contains the data. •row_index_num Required The row number in table_array from which the matching value will be returned range_lookup Optional. A logical value that specifies whether you want HLOOKUP to find an exact match or an approximate match. If TRUE or omitted, an approximate match is returned. In other words, if an exact match is not found, the next largest value that is less than lookup_value is returned. If FALSE, HLOOKUP will find an exact match. If one is not found, the error value #N/A is returned. Description: THE FUNCTION Syntax: =INDEX(array,row_num,[column_num]) Arguments: •array Required A range of cells or an array constant. •row_num Optional Selects the row in array from which to return a value. oIf row_num is omitted, column_num is required. •column_num Optional Selects the column in array from which to return a value. oIf column_num is omitted, row_num is required. Description: • Returns the value of an element in a table or an array, selected by the row and column number indexes. Microsoft® Excel® Lookup Functions THE FUNCTION Syntax: =MATCH(lookup_value, lookup_array, [match_type]) Arguments: •lookup_value Required The value that you want to match in lookup_array. •lookup_array Required The range of cells being searched. •match_type Optional Specifies how Excel matches lookup_value with values in lookup_array. oThe number -1, 0, or 1 Description: • Searches for a specified item in a range of cells, and then returns the relative position of that item in the range Microsoft® Excel® Lookup Functions MICROSOFT EXCEL DATE FUNCTIONS DATE =DATE(year,month,day) YEAR =YEAR(serial_number) MONTH =MONTH(serial_number) DAY =DAY(serial_number) TODAY =TODAY() NOW =NOW() DATEDIF =DATEDIF(startdate,enddate,interval) 35 YEARFRAC =YEARFRAC(start_date,end_date,[basis]) THE FUNCTION Syntax: =DATE(year,month,day) Arguments: •year Required The value of the year argument can include one to four digits. •month Required A positive or negative integer representing the month of the year from 1 to 12 (January to December). •day Required A positive or negative integer representing the day of the month from 1 to 31. Description: • Returns the sequential serial number that represents a particular date. Microsoft® Excel® Date Functions THE FUNCTION Syntax: =YEAR(serial_number) Arguments: •serial_number Required The date of the year you want to find. Description: • Returns the year corresponding to a date. Microsoft® Excel® Date Functions THE FUNCTION Syntax: =MONTH(serial_number) Arguments: •serial_number Required The date of the month you want to find. Description: • Returns the month of a date represented by a serial number. Microsoft® Excel® Date Functions THE FUNCTION Syntax: =DAY(serial_value) Arguments: •serial_value Required The date of the day you want to find. Description: • Returns the day of a date, represented by a serial number. Microsoft® Excel® Date Functions THE FUNCTION Syntax: =TODAY() Arguments: None Description: • Returns the serial number of the current date. Microsoft® Excel® Date Functions THE FUNCTION Syntax: =NOW() Arguments: None Description: • Returns the serial number of the current date and time. Microsoft® Excel® Date Functions THE FUNCTION Syntax: =YEARFRAC(start_date,end_date,[basis]) Arguments: •start_date Required A date that represents the start date. •end_date Required A date that represents the end date. •basis Optional The type of day count basis to use. Description: • Calculates the fraction of the year represented by the number of whole days between two dates (the start_date and the end_date). Microsoft® Excel® Date Functions THE COUNT BASIS FUNCTION-DAY 0 – This value is used for US (NASD) date systems that assume 30 days are in a month and 360 days are in one year. If no basis value is specified, a value of 0 is used. 1 – A value of 1 should be used for the basis if you want your calculations based on the actual number of days in any given month or year. 2 – This value uses the actual number of days in any given month but assumes there are only 360 days in a year. 3 – This value is similar to the previous option as it uses the actual number of days in any given month, but it assumes there are 365 days in each year. That is, it disregards leap years. 4 – This value is similar to 0 (30 days in each month and 360 days in a year), but it assumes a European date system. THE FUNCTION Syntax: =DATEDIF(startdate,enddate,interval) Arguments: •startdate Required A date that represents the start date. •enddate Required A date that represents the end date. •interval Required The type of day count basis to use. Microsoft® Excel® Date Functions THE FUNCTION Arguments: •interval Required The type of day count basis to use. Description: • Computes the difference between two dates in a variety of different intervals. Microsoft® Excel® Date Functions MICROSOFT EXCEL TIME FUNCTIONS HOUR =HOUR(serial_number) MINUTE =MINUTE(serial_number) SECOND =SECOND(serial_number) THE FUNCTION Syntax: =HOUR(serial_number) Arguments: •serial_number Required The time that contains the hour you want to find. Description: • Returns the hour of a time value. Microsoft® Excel® Time Functions THE FUNCTION Syntax: =MINUTE(serial_number) Arguments: •serial_number Required The time that contains the minute you want to find. Description: • Returns the minutes of a time value. Microsoft® Excel® Time Functions THE FUNCTION Syntax: =SECOND(serial_number) Arguments: •serial_number Required The time that contains the seconds you want to find. Description: • Returns the seconds of a time value. Microsoft® Excel® Time Functions MICROSOFT EXCEL TEXT FUNCTIONS FIND =FIND(find_text,within_text,[start_num]) LEFT =LEFT(text,[num_chars]) LEN =LEN(text) RIGHT =RIGHT(text,[num_chars]) CONCATENATE (including &) =CONCATENATE(text1, [text2], ...) UPPER =UPPER(text) LOWER =LOWER(text) PROPER =PROPER(text) TRIM =TRIM(text) MID =MID(text, start_num, num_chars) THE FUNCTION Syntax: =FIND(find_text,within_text,[start_num]) Arguments: •find_text Required The text you want to find. •within_text Required The text string containing the text you want to find. •start_num Optional Specifies the character at which to start the search. Description: • Locates one text string within a second text string, and returns the number of the starting position of the first text string from the first character of the second text string Microsoft® Excel® Text Functions THE FUNCTION Syntax: =LEFT(text,[num_chars]) Arguments: •text Required The text string that contains the characters you want to extract. •num_chars Optional Specifies the number of characters you want LEFT to extract. Description: • Returns the first character or characters in a text string, based on the number of characters you specify Microsoft® Excel® Text Functions THE FUNCTION Syntax: =LEN(text) Arguments: •text Required The text whose length you want to find. Description: • Returns the number of characters in a text string. Microsoft® Excel® Text Functions THE FUNCTION Syntax: =RIGHT(text,[num_chars]) Arguments: •text Required The text string that contains the characters you want to extract. •num_chars Optional Specifies the number of characters you want RIGHT to extract. Description: • Returns the last character or characters in a text string, based on the number of characters you specify. Microsoft® Excel® Text Functions THE FUNCTION Syntax: =CONCATENATE(text1, [text2], ...) Arguments: •text1 Required The first text item to be concatenated. •text2 Optional Additional text items, up to a maximum of 255 items, which must be separated by commas. Description: • Joins up to 255 text strings into one text string. Microsoft® Excel® Text Functions THE FUNCTION Syntax: =UPPER(text) Arguments: •text Required The text you want converted to uppercase. Description: • Converts text to uppercase. Microsoft® Excel® Text Functions THE FUNCTION Syntax: =LOWER(text) Arguments: •text Required The text you want converted to lowercase. Description: • Converts all uppercase letters in a text string to lowercase. Microsoft® Excel® Text Functions THE FUNCTION Syntax: =PROPER(text) Arguments: •text Required Text enclosed in quotation marks, a formula that returns text, or a reference to a cell containing the text you want to partially capitalize. Description: • Capitalizes the first letter in a text string and any other letters in text that follow any character other than a letter. Microsoft® Excel® Text Functions THE FUNCTION Syntax: =TRIM(text) Arguments: •text Required is the text from which you want spaces removed. Description: Removes all spaces from text except for single spaces between words. Use TRIM on text that you have received from another application that may have irregular spacing. Microsoft® Excel® Text Functions THE FUNCTION Syntax: =MID(text, start_num, num_chars) Arguments: Text Required. The text string containing the characters you want to extract. Start_num Required. The position of the first character you want to extract in text. The first character in text has start_num 1, and so on. Num_chars Required. Specifies the number of characters you want MID to return from text. Description: • MID returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify. Microsoft® Excel® Text Functions MICROSOFT EXCEL DATABASE FUNCTIONS DAVERAGE =DAVERAGE(database,field,criteria) DCOUNT =DCOUNT(database,field,criteria) DMAX =DMAX(database,field,criteria) DMIN =DMIN(database,field,criteria) DSUM =DSUM(database,field,criteria) THE FUNCTION Syntax: =DAVERAGE(database,field,criteria) Arguments: •database Required The range of cells that makes up the list or database. •field Required Indicates which column is used in the function. •criteria Required The range of cells that contains the conditions you specify. Description: •Averages the values in a field (column) of records in a list or database that match conditions you specify. Microsoft® Excel® Database Functions THE FUNCTION The average yield of apple trees over 10 feet in height. =DAVERAGE(A4:E10,"Yield",A1:B2) Microsoft® Excel® Database Functions THE FUNCTION The average yield of apple trees over 10 feet in height. =DAVERAGE(A4:E10,"Yield",A1:B2) Microsoft® Excel® Database Functions THE FUNCTION The average yield of apple trees over 10 feet in height. =DAVERAGE(A4:E10,"Yield",A1:B2) Microsoft® Excel® Database Functions THE FUNCTION The average yield of apple trees over 10 feet in height. =DAVERAGE(A4:E10,"Yield",A1:B2) Microsoft® Excel® Database Functions THE FUNCTION The average yield of apple trees over 10 feet in height. =DAVERAGE(A4:E10,"Yield",A1:B2) =12 Microsoft® Excel® Database Functions THE FUNCTION The average age of all trees in the database. =DAVERAGE(A4:E10,3,A4:E10) Microsoft® Excel® Database Functions THE FUNCTION The average age of all trees in the database. =DAVERAGE(A4:E10, 3,A4:E10) Microsoft® Excel® Database Functions THE FUNCTION The average age of all trees in the database. =DAVERAGE(A4:E10, 3,A4:E10) Microsoft® Excel® Database Functions THE FUNCTION The average age of all trees in the database. =DAVERAGE(A4:E10, 3,A4:E10) Microsoft® Excel® Database Functions THE FUNCTION The average age of all trees in the database. =DAVERAGE(A4:E10, 3,A4:E10) =13 Microsoft® Excel® Database Functions THE FUNCTION The maximum profit of apple and pear trees. =DMAX(A4:E10,"Profit",A1:A3) Microsoft® Excel® Database Functions THE FUNCTION The maximum profit of apple and pear trees. =DMAX(A4:E10,"Profit",A1:A3) Microsoft® Excel® Database Functions THE FUNCTION The maximum profit of apple and pear trees. =DMAX(A4:E10,"Profit",A1:A3) Microsoft® Excel® Database Functions THE FUNCTION The maximum profit of apple and pear trees. =DMAX(A4:E10,"Profit",A1:A3) Microsoft® Excel® Database Functions THE FUNCTION The maximum profit of apple and pear trees. =DMAX(A4:E10,"Profit",A1:A3) =105 Microsoft® Excel® Database Functions THE FUNCTION The minimum profit of apple trees over 10 in height. =DMIN(A4:E10,"Profit",A1:B2) Microsoft® Excel® Database Functions THE FUNCTION The minimum profit of apple trees over 10 in height. =DMIN(A4:E10,"Profit",A1:B2) Microsoft® Excel® Database Functions THE FUNCTION The minimum profit of apple trees over 10 in height. =DMIN(A4:E10,"Profit",A1:B2) Microsoft® Excel® Database Functions THE FUNCTION The minimum profit of apple trees over 10 in height. =DMIN(A4:E10,"Profit",A1:B2) Microsoft® Excel® Database Functions THE FUNCTION The minimum profit of apple trees over 10 in height. =DMIN(A4:E10,"Profit",A1:B2) =75 Microsoft® Excel® Database Functions THE FUNCTION This function looks at the records of apple trees between a height of 10 and 16 and counts how many of the Age fields in those records contain numbers. =DCOUNT(A4:E10,"Age",A1:F2) Microsoft® Excel® Database Functions THE FUNCTION This function looks at the records of apple trees between a height of 10 and 16 and counts how many of the Age fields in those records contain numbers. =DCOUNT(A4:E10,"Age",A1:F2) Microsoft® Excel® Database Functions THE FUNCTION This function looks at the records of apple trees between a height of 10 and 16 and counts how many of the Age fields in those records contain numbers. =DCOUNT(A4:E10,"Age",A1:F2) Microsoft® Excel® Database Functions THE FUNCTION This function looks at the records of apple trees between a height of 10 and 16 and counts how many of the Age fields in those records contain numbers. =DCOUNT(A4:E10,"Age",A1:F2) Microsoft® Excel® Database Functions THE FUNCTION This function looks at the records of apple trees between a height of 10 and 16 and counts how many of the Age fields in those records contain numbers. =DCOUNT(A4:E10,"Age",A1:F2) =1 Microsoft® Excel® Database Functions THE FUNCTION The total profit from apple trees. =DSUM(A4:E10,"Profit",A1:A2) Microsoft® Excel® Database Functions THE FUNCTION The minimum profit of apple trees over 10 in height. =DSUM(A4:E10,"Profit",A1:A2) Microsoft® Excel® Database Functions THE FUNCTION The minimum profit of apple trees over 10 in height. =DSUM(A4:E10,"Profit",A1:A2) Microsoft® Excel® Database Functions THE FUNCTION The minimum profit of apple trees over 10 in height. =DSUM(A4:E10,"Profit",A1:A2) Microsoft® Excel® Database Functions THE FUNCTION The minimum profit of apple trees over 10 in height. =DSUM(A4:E10,"Profit",A1:A2) =225 Microsoft® Excel® Database Functions SORTING DATA BY ONE AND MULTIPLE COLUMNS 1. Select the data that you want to sort Select a range of data, such as A1:L5 (multiple rows and columns) or C1:C80 (a single column). The range can include titles that you created to identify columns or rows. 2. Sort quickly 1. Select a single cell in the column on which you want to sort. 2. Click Button Image to perform an ascending sort (A to Z or smallest number to largest). 93 3. Click to perform a descending sort (Z to A or largest number to smallest). SORTING DATA BY ONE AND MULTIPLE COLUMNS 3. Sort by specifying criteria You can choose the columns on which to sort by clicking the Sort command in the Sort & Filter group on the Data tab. 1. Select a single cell anywhere in the range that you want to sort. 2. On the Data tab, in the Sort & Filter group, click Sort. The Sort dialog box appears. 3. In the Sort by list, select the first column on which you want to sort. 4. In the Sort On list, select either Values, Cell Color, Font Color, or Cell Icon. 94 5. In the Order list, select the order that you want to apply to the sort operation — alphabetically or numerically ascending or descending (that is, A to Z or Z to A for text or lower to higher or higher to lower for numbers). APPLYING AUTO-FILTER ON ONE AND MULTIPLE COLUMNS By filtering information in a worksheet, you can find values quickly. You can filter on one or more columns of data. With filtering, you can control not only what you want to see, but what you want to exclude. You can filter based on choices you make from a list, or you can create specific filters to focus on exactly the data that you want to see. 95 When you filter data, entire rows are hidden if values in one or more columns don't meet the filtering criteria. APPLYING AUTO-FILTER ON ONE AND MULTIPLE COLUMNS 1. Select the data that you want to filter 1. On the Data tab, in the Sort & Filter group, click Filter. 2. Click the arrow in the column header to display a list in which you can make filter choices. 96 Note Depending on the type of data in the column, Microsoft Excel displays either Number Filters or Text Filters in the list. APPLYING AUTO-FILTER ON ONE AND MULTIPLE COLUMNS 2. Filter by selecting values or searching 97 Selecting values from a list and searching are the quickest ways to filter. When you click the arrow in a column that has filtering enabled, all values in that column appear in a list. APPLYING AUTO-FILTER ON ONE AND MULTIPLE COLUMNS 1 Use the Search box to enter text or numbers on which to search 2 Select and clear the check boxes to show values that are found in the column of data 3 Use advanced criteria to find values that meet specific conditions 1. To select by values, in the list, clear the (Select All) check box. This removes the check marks from all the check boxes. Then, select only the values you want to see, and click OK to see the results. 98 2. To search on text in the column, enter text or numbers in the Search box. Optionally, you can use wildcard characters, such as the asterisk (*) or the question mark (?). Press ENTER to see the results. APPLYING AUTO-FILTER ON ONE AND MULTIPLE COLUMNS 3. Filter data by specifying conditions 1. Point to either Number Filters or Text Filters in the list. A menu appears that allows you to filter on various conditions. 2. Choose a condition and then select or enter criteria. Click the And button to combine criteria (that is, two or more criteria that must both be met), and the Or button to require only one of multiple conditions to be met. 3. Click OK to apply the filter and get the results you expect. 99 By specifying conditions, you can create custom filters that narrow down the data in the exact way that you want. You do this by building a filter. If you've ever queried data in a database, this will look familiar to you. CALCULATING SUBTOTALS You can use Excel 2010's Subtotals feature to subtotal data in a sorted list. To subtotal a list, you first sort the list on the field for which you want the subtotals, and then you designate the field that contains the values you want summed — these don't have to be the same fields in the list. Excel does not allow you to subtotal a list formatted as a table. 100 You must first convert your table into a normal range of cells. CALCULATING SUBTOTALS How to add a subtotal to a worksheet? 1. Sort the list on the field for which you want subtotals inserted. 101 2. Click the Subtotal button in the Outline group on the Data tab. CALCULATING SUBTOTALS 3. Select the field for which the subtotals are to be calculated in the At Each Change In drop-down list. 4. Specify the type of totals you want to insert in the Use function dropdown list. When you use the Subtotals feature, you aren't restricted to having the values in the designated field added together with the SUM function. You can instead have Excel return the number of entries with the COUNT function, the average of the entries with the AVERAGE function, the highest entry with the MAXIMUM function, the lowest entry with the MINIMUM function, or even the product of the entries with the PRODUCT function. 5. Select the check boxes for the field(s) you want to total in the Add Subtotal To list box. 102 6. Click OK. CALCULATING SUBTOTALS 103 Excel adds the subtotals to the worksheet. APPLYING ADVANCED AUTO-FILTERS 104 Insert at least three blank rows above the range that can be used as a criteria range. The criteria range must have column labels. Make sure there is at least one blank row between the criteria values and the range. APPLYING ADVANCED AUTO-FILTERS 105 In the rows below the column labels, type the criteria you want to match. APPLYING ADVANCED AUTO-FILTERS 1. Click a cell in the range. 2. On the Data menu, point to Filter, and then click Advanced Filter. 3. To filter the range by hiding rows that don't match your criteria, click Filter the list, in-place. To filter the range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows. 4. In the Criteria range box, enter the reference for the criteria range, including the criteria labels.(A1:C3) To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, clickCollapse Dialog . 106 5. To change how the data is filtered, change the values in the criteria range and filter the data again. PIVOT TABLES & PIVOT CHARTS 107 Excel 2010 has an option of creating pivot table, as name implies it pivots down the existing data table and tries to make user understand the crux of it. PIVOT TABLES & PIVOT CHARTS 108 To start out with making pivot table, make sure that all rows and columns are selected. Navigate to Insert tab, click PivotTable. PIVOT TABLES & PIVOT CHARTS You will reach Create Pivot Table dialog box. Excel fills in data range from first to last selected columns and rows. You can also specify any external data source to be used. Finally choose worksheet to save the pivot table report. 109 Click OK to proceed further PIVOT TABLES & PIVOT CHARTS Pivot table will appear. 110 Now we will populate this table with data fields which is being present at the right side of the Excel window. PIVOT TABLES & PIVOT CHARTS We start off with enabling Platform field, and then other fields. 111 Excel start filling cells in a sequence you want to populate. The Platform field will come first in the Pivot Table as shown in screen shot. PIVOT TABLES & PIVOT CHARTS For creating chart of pivot table, go to Insert tab, click Column select an appropriate chart type. 112 In this example we will create a simple 3-D Column chart. PIVOT TABLES & PIVOT CHARTS 113 Chart content can be changed by using the options at the bottom-left of its area. INSERT OR DELETE A DROPDOWN LIST To make data entry easier in Excel, or to limit entries to certain items that you define, you can create a drop-down list of valid entries that is compiled from cells elsewhere in the workbook. To create a drop-down list from a range of cells, use the Data Validation command in the Data Tools group on the Data tab. 114 1. To create a list of valid entries for the drop-down list, type the entries in a single column or row without blank cells. For example: INSERT OR DELETE A DROPDOWN LIST 2. NOTE You may want to sort the data in the order that you want it to appear in the drop-down list. 3. If you want to use another worksheet, type the list on that worksheet, and then define a name for the list. 4. Select the cell where you want the drop-down list. 5. On the Data tab, in the Data Tools group, click Data Validation. 115 6. In the Data Validation dialog box, click the Settings tab. INSERT OR DELETE A DROPDOWN LIST 7. In the Allow box, click List. 8. To specify the location of the list of valid entries, do one of the following: • If the list is in the current worksheet, enter a reference to your list in the Source box. • If the list is on a different worksheet, enter the name that you defined for your list in the Source box. 116 9. Make sure that the In-cell dropdown check box is selected WHAT IF ANALYSIS (KENDRA & MCINTOSH ONLY) • Goal Seeking function • Can work through multiple scenarios • Can have Data tables • Example: Find the interest rate that is needed to finance $25,000 car over 5 years (60 months) with a payment no more than $450. FORM CONTROLS (KENDRA & MCINTOSH ONLY) Where to find them? In Excel 2010, click the File tab, and then click Options. click the Customize Ribbon tab, and then in the Customize the Ribbon box, select the Developer check box. FORM CONTROLS List box example 1. To add a list box click the Developer tab, click Insert in the Controls group, and then click List Box Form (Control) under Form Controls. FORM CONTROLS 2. Click the worksheet location where you want the upper-left corner of the list box to appear, and then drag the list box to where you want the lower-right corner of the list box to be. In this example, create a list box that covers cells B2:E10. 3. In the Controls group, click Properties. FORM CONTROLS 4. In the Format Object window, type the following information, and then click OK. To specify the range for the list, type H1:H20 in the Input range box. To put a number value in cell G1 (depending on which item is selected in the list), type G1 in the Cell link box. Note The INDEX() formula uses the value in G1 to return the correct list item. Under Selection type, make sure that the Single option is selected. Note The Multi and Extend options are only useful when you are using a Microsoft Visual Basic for Applications procedure to return the values of the list. Note also that the 3-D shading check box adds a three-dimensional look to the list box. FORM CONTROLS 5. The list box should display the list of items. To use the list box, click any cell so that the list box is not selected. If you click an item in the list, cell G1 is updated to a number that indicates the position of the item that is selected in the list. The INDEX formula in cell A1 uses this number to display the item's name. FORM CONTROLS Combo box example 1. To add a combo box click the Developer tab, click Insert, and then click Combo Box under Form Controls. FORM CONTROLS 2. Click the worksheet location where you want the upper-left corner of the combo box to appear, and then drag the combo box to where you want the lower-right corner of the list box to be. In this example, create a combo box that covers cells B2:E2. FORM CONTROLS 3.Right-click the combo box, and then click Format Control. FORM CONTROLS 4. Type the following information, and then click OK: • To specify the range for the list, type H1:H20 in the Input range box. • To put a number value in cell G1 (depending on which item is selected in the list), type G1 in the Cell link box. Note The INDEX formula uses the value in G1 to return the correct list item. • In the Drop down lines box, type 10. This entry determines how many items will be displayed before you have to use a scroll bar to view the other items. Note The 3-D shading check box is optional. It adds a three-dimensional look to the drop-down or combo box. FORM CONTROLS 5. The drop-down box or combo box should display the list of items. To use the drop-down box or combo box, click any cell so that the object is not selected. When you click an item in the drop-down box or combo box, cell G1 is updated to a number that indicates the position in the list of the item selected. The INDEX formula in cell A1 uses this number to display the item's name. FORM CONTROLS Spin button example 1. To add a spin button click the Developer tab, click Insert, and then click Spin Button under Form Controls. 2. Click the worksheet location where you want the upper-left corner of the spin button to appear, and then drag the spin button to where you want the lowerright corner of the spin button to be. In this example, create a spin button that covers cells B2: B3. FORM CONTROLS 3. Right-click the spin button, and then click Format Control. FORM CONTROLS 4. Type the following information, and then click OK:In the Current value box, type 1. This value initializes the spin button so that the INDEX formula will point to the first item in the list. In the Minimum value box, type 1. This value restricts the top of the spin button to the first item in the list. In the Maximum value box, type 20. This number specifies the maximum number of entries in the list. In the Incremental change box, type 1. This value controls how much the spin button control increments the current value. To put a number value in cell G1 (depending on which item is selected in the list), type G1 in the Cell link box. FORM CONTROLS 5. Click any cell so that the spin button is not selected. When you click the up control or down control on the spin button, cell G1 is updated to a number that indicates the current value of the spin button plus or minus the incremental change of the spin button. This number then updates the INDEX formula in cell A1 to show the next or previous item. The spin button value will not change if the current value is 1 and you click the down control, or if the current value is 20 and you click the up control. FORM CONTROLS Scroll bar example 1. To add a scroll bar in Excel 2010 and Excel 2007, click the Developer tab, click Insert, and then click Scroll Bar under Form Controls. FORM CONTROLS 2. Click the worksheet location where you want the upper-left corner of the scroll bar to appear, and then drag the scroll bar to where you want the lower-right corner of the scroll bar to be. In this example, create a scroll bar that covers cells B2:B6 in height and is about one-fourth of the width of the column. FORM CONTROLS 3. Right-click the scroll bar, and then click Format Control. FORM CONTROLS 4.Type the following information, and then click OK: In the Current value box, type 1. This value initializes the scroll bar so that the INDEX formula will point to the first item in the list. In the Minimum value box, type 1. This value restricts the top of the scroll bar to the first item in the list. In the Maximum value box, type 20. This number specifies the maximum number of entries in the list. In the Incremental change box, type 1. This value controls how many numbers the scroll bar control increments the current value. In the Page change box, type 5. This value controls how much the current value will be incremented if you click inside the scroll bar on either side of the scroll box). To put a number value in cell G1 (depending on which item is selected in the list), type G1 in the Cell link box. FORM CONTROLS 5. Click any cell so that the scroll bar is not selected. When you click the up or down control on the scroll bar, cell G1 is updated to a number that indicates the current value of the scroll bar plus or minus the incremental change of the scroll bar. This number is used in the INDEX formula in cell A1 to show the item next to or before the current item. You can also drag the scroll box to change the value or click in the scroll bar on either side of the scroll box to increment it by 5 (the Page change value). The scroll bar will not change if the current value is 1 and you click the down control, or if the current value is 20 and you click the up control. DATA VALIDATION (KENDRA & MCINTOSH ONLY) It is used to control the type of data or the values that users enter into a cell. Data validation options are located on the Data tab, in the Data Tools group. You configure data validation in the Data Validation dialog box. DATA VALIDATION When is data validation useful? Restrict numbers outside a specified range For example, you can specify a minimum limit of deductions to two times the number of children in a particular cell. Restrict dates outside a certain time frame For example, you can specify a time frame between today's date and 3 days from today's date. Restrict times outside a certain time frame For example, you can specify a time frame for serving breakfast between the time when the restaurant opens and 5 hours after the restaurant opens. Limit the number of text characters For example, you can limit the allowed text in a cell to 10 or fewer characters. Similarly, you can set the specific length for a full name field (C1) to be the current length of a first name field (A1) and a last name field (B1), plus 10 characters. Validate data based on formulas or values in other cells For example, you can use data validation to set a maximum limit for commissions and bonuses of $3,600, based on the overall projected payroll value. If users enter more than $3,600 in the cell, they see a validation message. DATA VALIDATION Data validation messages: CON TYPE USE TO Stop Prevent users from entering invalid data in a cell. A Stop alert message has two options: Retry or Cancel. Warning Warn users that the data they entered is invalid, without preventing them from entering it. When a Warning alert message appears, users can click Yes to accept the invalid entry,No to edit the invalid entry, or Cancel to remove the invalid entry. Information Inform users that the data they entered is invalid, without preventing them from entering it. This type of error alert is the most flexible. When an Information alert message appears, users can click OK to accept the invalid value or Cancel to reject it. PROTECTING WORKSHEETS (KENDRA & MCINTOSH ONLY) By default, all cells in an Excel spreadsheet are locked. This makes it very easy to protect all data in a single worksheet simply by applying the Protect Sheet option. Unlocking specific cells permits changes to be made to these cells after the protect sheet option has been applied. Often certain areas of a worksheet are unlocked so that new data can be added. Cells containing formulas, functions, or other important data are kept locked so that once the protect sheet option has been applied, these cells cannot be changed. PROTECTING WORKSHEETS Protect a worksheet in Excel 1. Open an Excel file to protect. If you open a new file all cells in the worksheet will be protected. If you wish, follow the example in step one to unlock certain cells in a worksheet. 2. Click on the Home tab. 3. Choose the Format option on the ribbon to open the drop down list. 4. Click on Protect Sheet option at the bottom of the list to open the Protect Sheet dialog box. 5. This dialog box contains a number of options when protecting the worksheet. 6. The first option is to add a password to prevent worksheet protection from being turned off. This password does not stop users from opening the worksheet and viewing the contents. PROTECTING WORKSHEETS 7. Next there a number of options that can be turned on or off with check boxes. The first two allow a user to drag select locked and unlocked cells. If these two are turned off, users will not be able to make any changes to a worksheet - even if it contains unlocked cells. 8. The remaining options allow users to carry out specific tasks on a protected worksheet, such as formatting cells and sorting data. 9. These options, however, do not all work the same. For instance, if the format cells option is checked off when a sheet is protected, all cells can be formatted. The sort option, on the other hand, works only on those cells that have been unlocked before the sheet was protected. 10. When you have selected the appropriate options, click OK. PROTECTING WORKSHEETS Turning off worksheet protection 1. Click on the Home tab. 2. Choose the Format option on the ribbon to open the drop down list. 3. Click on Unprotect Sheet option at the bottom of the list. HIDING COLUMNS (KENDRA & MCINTOSH ONLY) Hide one or more rows or columns 1. Select the rows or columns that you want to hide. 2. On the Home tab, in the Cells group, click Format. 3. Do one of the following: • Under Visibility, point to Hide & Unhide, and then click Hide Rows or Hide Columns. • Under Cell Size, click Row Height or Column Width, and then type 0 in the Row Height or Column Widthbox. TIP You can also right-click a row or column (or a selection of multiple rows or columns), and then click Hide. HIDING COLUMNS Display one or more hidden rows or columns 1. Do one of the following: • To display hidden rows, select the row above and below the rows that you want to unhide. • To display hidden columns, select the columns adjacent to either side of the columns that you want to unhide. • To display the first hidden row or column on a worksheet, select it by typing A1 in the Name Box next to theformula bar. TIP You can also select it by using the Go To dialog box. On the Home tab, under Editing, click Find & Select, and then click Go To. In the Reference box, type A1, and then click OK. HIDING COLUMNS 2. On the Home tab, in the Cells group, click Format. 3. Do one of the following: • Under Visibility, point to Hide & Unhide, and then click Unhide Rows or Unhide Columns. • Under Cell Size, click Row Height or Column Width, and then type the value that you want in the Row Heightor Column Width box. TIP You can also right-click the selection of visible rows and columns that surround the hidden rows and columns, and then click Unhide. HIDING COLUMNS Display all hidden rows and columns at the same time 1. To select all cells on a worksheet, do one of the following: • Click the Select All button. Select All Button • Press CTRL+A. NOTE If the worksheet contains data and the active cell is above or to the right of the data, pressing CTRL+A selects the current region. Pressing CTRL+A a second time selects the entire worksheet. HIDING COLUMNS 2. On the Home tab, in the Cells group, click Format. 3. Do one of the following: • Under Visibility, point to Hide & Unhide, and then click Unhide Rows or Unhide Columns. • Under Cell Size, click Row Height or Column Width, and then type the value that you want in the Row Height or Column Width box. HIDING COLUMNS Unhide the first row or column of the worksheet 1. To select the first hidden row or column on the worksheet, do one of the following: • In the Name Box next to the formula bar, type A1. • On the Home tab, in the Editing group, click Find & Select, and then click Go To. In the Reference box, typeA1, and then click OK. 2. On the Home tab, in the Cells group, click Format. HIDING COLUMNS 3. Do one of the following: • Under Visibility, point to Hide & Unhide, and then click Unhide Rows or Unhide Columns. • Under Cell Size, click Row Height or Column Width, and then type the value that you want in the Row Height or Column Width box. Access Review DATABASE DESIGN Basic Terminology: A table consists of data that is arrayed in rows and columns. A row of data is called a record. A column of data is called a field. Thus, a record is a set of related fields. The fields in a table 152 should be related to one another in some way. BASIC TERMINOLOGY Primary key field is a field in which each record has a unique value. e.g. The SSN Compound Primary Key is used when there is no single field whose values are all different. In that case, two or more fields are combined. The combination of the fields’ values should be unique. Foreign key is the primary key of another table. e.g. suppose we need to link the employee table with the Hours worked table for payroll purposes. The Employee ID number (EIN) is the primary key of the employees table but the foreign key of the hours worked table. 153 *Every foreign key must be associated with a primary key in another table. BASIC TERMINOLOGY A form is a database object that is created from an existing table to make the process of entering data more user-friendly A query is the database equivalent of a question that is posed about data in a table (or tables). 154 Queries can be designed to search multiple tables but these tables should be connected by a join operation. DATABASE DESIGN Database design concepts: Entities an entity is a tangible thing or an event. It is a person, place, thing or concept about which data can be collected. Consider the following examples: 1) The database of a video store would have one entity named video and another named customer (These are physical entities). 2) Organizations incur expenses from paying hourly employees and purchasing materials from suppliers. Hours worked and purchases are event entities in the database of most organizations. 3) The library lends books for free. If you were to think of checking out a book as a sales transaction for zero revenue, how would you handle the revenue generating event? 155 The event entity here is the number of checkouts. DATABASE DESIGN Relationships you should consider the relationship of each entity to the other entities you have identified. Cardinality of any relationship can be one-to-one, one-to-many, or many-tomany. A one-to-one relationship is like A book is published by one company or A shark lives in one place (the ocean). There is a many-to-many relationship between the records in the doctor table and records in the patient table because doctors have many patients, and a patient could have several doctors; 156 A one-to-many relation between the department table and the doctor table because each doctor may work for only one department, but one department could have many doctors. DATABASE DESIGN A book can have more than one author. An author can write more than one book. How would you describe the relationship between authors and books? Many-to-many A member can borrow any number of books at one checkout. A book can be checked out more than once. How would you describe the relationship between books and checkouts? 157 Many-to-many DATABASE DESIGN Attributes an attribute is a characteristic of an entity. These attributes become the table’s field. E.g. what are the attributes for the entity “Customer”? Customer ID, First name, Surname, Date of Birth, Address and Phone no. What are the attributes for the entity “Fashion Model”? 158 Name, Height, Weight, Dress size, Hair color and Eye color. DATABASE DESIGN RULES Rule 1: You do not need a table for the business The database represents the entire business. Thus in the practice example* The library is not an entity. *practice problem at the end of tutorial A. Rule 2: Identify the entities in the business description 159 In our example the entities are Members, employees and books. DATABASE DESIGN RULES Rule 3: Look for relationships among the entities look for relationships between entities; one-to-many and many-to-many. In our example: one-to-many: a member can check out more than one book. Rule 4: Look for attributes of each entity and designate a primary key. Primary Key Attributes of members: name, DOB, phone no., email address, member ID card number …etc. Employees: name, # of hours worked, job title,…etc. Foreign key 160 Books: name, authors, type, status, member ID card number…etc. DATABASE DESIGN RULES Rule 5: Avoid data redundancy you should not include extra (redundant) fields in a table. Redundant fields take up extra disk space and lead to data entry errors because the same value must be entered in multiple tables. Rule 6: Do not include a field if it can be calculated from other fields A calculated field is made using the query generator as we will see later. 161 ** You should realize the importance of accuracy, case sensitivity…etc in designing databases. METADATA & HIERARCHY OF DATA Metadata: Data about data. Metadata describes how and when and by whom a particular set of data was collected, and how the data is formatted. A text document's metadata may contain information about how long the document is, who the author is, when the document was written, and a short summary of the document. 162 Hierarchy of Data: refers to the systematic organization of data, often in a hierarchical form. Data organization involves fields, records, files and so on. DATA DICTIONARY Data Dictionary: In database management systems, a file that defines the basic organization of a database. A data dictionary contains a list of all files in the database, the number of records in each file, and the names and types of each field. Most database management systems keep the data dictionary hidden from users to prevent them from accidentally destroying its contents. 163 Data dictionaries do not contain any actual data from the database, only bookkeeping information for managing it. Without a data dictionary, however, a database management system cannot access data from the database. CREATING TABLES Create tab Table design (in the tables group) Fill in the table’s fields. Choose a suitable data type for each field. For example text Last Name Date/time Date Hired Yes/No US Citizen 164 Change the lengths of the text fields from 255 to 30 spaces. CREATING TABLES We need to make the Employee ID a primary key: Select the Employee ID field then in the Table tools Design click Primary Key tab After you finish click the File tab Save object as then name your table 165 Note that this is different from Save Database as which saves the whole database. CREATING COMPOUND PRIMARY KEY The two fields must be appear one after the other in the table definition screen (plan ahead for that format). Highlight one field, hold down the control key and highlight the next field. 166 Go to table tools design tab Primary Key ADDING RECORDS TO A TABLE Double click the table’s name in the navigation pane at the left of the screen then start typing data directly into the cells. Enter your data one field value at a time. Each time you finish entering a value, press Enter to move the cursor to the next cell. After you enter the data in the last cell in a row, the cursor moves to the first cell in the next row and Access automatically saves the record 167 No need to save through the File tab. CREATING QUERIES Using Calculated Fields in Queries: E.g. suppose we have the following table. 168 if you have an existing field containing the number of boxes of Girl Scout cookies sold, you may want to see how much money was collected for each cookie sale. In this example, the boxes sold for $3.95 each. USING CALCULATED FIELDS IN QUERIES In this case we will create a calculated field in a query. Create tab Query design Don’t Forget the Colon. 169 Also the field name must be enclosed in square brackets. USING CALCULATED FIELDS IN QUERIES How to format the calculated field output? 1. select the output column by clicking the line above the calculated field expression. 2. the column darkens to indicate the selection. 170 3. Design tab property sheet format AVOIDING ERRORS WHEN MAKING CALCULATED FIELDS 1. Do not enter the expression in the criteria cell. Enter it in the Field cell. 2. Spell, capitalize, and space a field’s name exactly as you did in the table definition. 171 3. Don’t use parentheses or curly braces instead of the square brackets. “RELATING” TWO OR MORE TABLES BY THE JOIN OPERATION Suppose you want to see the last names, employee IDs, wage rates, salary status, and citizenship only for US citizens and hourly workers. Problem: the data is spread across two tables. Solution: add both tables and pull down the five fields you need. Step 1: Create tab Query design Step 2: Click one table name and hold down the ctrl button while choosing the other table name. 172 Step 3: start pulling down the fields you need and add the criteria expressions. 173 “RELATING” TWO OR MORE TABLES BY THE JOIN OPERATION “RELATING” TWO OR MORE TABLES BY THE JOIN OPERATION you can use calculated fields using more than one table. Just follow the same steps and add the calculated field in the 174 design view like what we did earlier. TOTALS QUERIES Assume that you want to see two pieces of information for hourly workers: 1. The average wage rate 2. 110 percent of the average rate Step1: Create the first query, click the design tab Totals button in the show/hide group. This will give us the average of the wage rate field. Note that: you should type the revised heading for the wage rate field, i.e. Average rate: wage rate. N.B. we need the average of this field. 175 Also to get the hourly workers only, enter Criteria=No. TOTALS QUERIES Now begin a new Query. But instead of basing it on a table, we will base it on the previous query. 176 Design the new query and create a calculated field inside it. USING THE DATE() FUNCTION IN QUERIES Access has two important date function features: 1. The built in Date() function which gives today’s date. 2. Date arithmetic lets you subtract one date from another to obtain the difference-in number of days- between two 177 calendar dates. USING THE DATE() FUNCTION IN QUERIES Suppose you want to give each employee a $1 bonus for each day the employee has worked. So, you need to calculate the number of days between the employee’s date of hire and the date the query is run. 178 Date arithmetic USING TIME ARITHMETIC IN QUERIES Access allows you to subtract the values of time fields to get an elapsed time. 179 In Access, subtracting one time from the other yields the decimal portion of a 24-hour day. E.g. if the employee worked 8 hours, the time arithmetic function yields 0.333. That’s why we multiply by 24. UPDATE QUERIES Suppose you want to give all non-salaried workers a $0.5 pay raise. If you have 3 workers change the wage rate data in the table. If you have 3000 workers it would be much faster and more accurate to change the wage rate by using an update query that adds $0.5 to each non-salaried employee’s wage 180 rate. UPDATE QUERIES First start by making a select query. 181 Then click the update button in the query type group. UPDATE QUERIES We will update only the nonsalaried workers by using a filter under the salaried field. 182 We will write the updated data in the Update to line in the QBE grid. UPDATE QUERIES When you run the query, the following warning message will appear. 183 Click yes, and the records will be updated. DELETE QUERIES Delete queries work like the update queries. E.g. Suppose your company is purchased by the state of Delaware. So you need to delete or “fire” all employees who are not exclusively Delaware residents. 184 <> not SCENARIO You have a table of medicines. One of them is now banned. Create a query with the new requirements. So what is the type of this query? 185 Delete Query PARAMETER QUERIES Suppose you want to know how many hours a particular employee has worked. 1. Run a select query. 186 2. You will get a message to enter the employee ID. Enter your employee ID and you will get the desired information PRACTICE QUERIES (P.33 37) 187 #2 Create a query that shows the last name, first name, date hired, and state for employees who live in Delaware or were hired after 12/31/99. The primary sort (ascending) is on last name, and the secondary sort (ascending) is on first name. The primary sort field must be to the left of the Secondary sort field in the query setup. N.B. you have 3 tables. Employee Last Name, First Name, Employee ID, Street Address, City, State, Zip, Date Hired, Us Citizen. Wage Data Employee ID, Wage Rate, Salaried. Hours Worked Employee ID, Week #, Hours. Use this table to solve the practice query. Field Table Sort Show Criteria 188 Or: ANSWER TO PRACTICE QUERY #2 Field Last Name First Name Date Hired State Table Employee Employee Employee Employee Sort Ascending Ascending >#12/31/1999# =“DE” Show Criteria 189 Or: PRACTICE QUERIES #6 Create a parameter query that shows the hours employees have worked. Have the parameter query prompt for the week number. The output headings should be Last Name, First Name, Week #, and hours. This query is for non-salaried employees only. N.B. you have 3 tables. Employee Last Name, First Name, Employee ID, Street Address, City, State, Zip, Date Hired, Us Citizen. Wage Data Employee ID, Wage Rate, Salaried. Hours Worked Employee ID, Week #, Hours. Field Table Show Criteria Or: 190 Sort ANSWER TO PRACTICE QUERY #6 Field Last Name First Name Week # Hours Salaried Table Employee Employee Hours Worked Hours Worked Wage Date Sort Show Criteria [Enter Week #] =No 191 Or: CREATING REPORTS Create basic ungrouped report: 192 Select the table create tab report CREATING REPORTS Create Grouped Report: Design tab Group and Sort button in the grouping and tools group. 193 Click the Add group button then select the desired table (Employee ID) CREATING REPORTS To total the hours worked by each employee: select the Hours column heading. Then on the Design tab totals button in the grouping and totals group Sum 194 Layout View CREATING REPORTS Design tab Report view from the views group 195 Report view (final view) MAKING FORMS First select the table or query you want to base the form on then select Create tab form When you create a form within another form this is called a subform The Subform is useful when the form is based on one or 196 more tables. MAKING FORMS Step 1: select the table create Form 197 Take the form into design view. Design tab make sure that the use control wizard option is selected click the subform/subreport button. MAKING FORMS Use your cursor to stretch out the box under your main menu. This dialog box will appear 198 Select use existing tables and Queries Next MAKING FORMS 199 Choose the required table from the list Next select choose from a list Next Finish. 200