Information Technology Topic
Finding Records by Criteria
- Read notes
- Flashcards
- Quiz
- Confident
Study focus - 3 things
- A criterion is a condition built from a field, a comparison and a value, such as Qty < 10, and a filter shows only the records that meet it
- A simple criterion is one condition; a complex criterion joins two or more with AND (every condition must be true, so fewer records) or OR (at least one must be true, so more records)
- Test the boundary value carefully: Qty < 10 and Qty <= 10 give different results, and the Find command locates a search term cell by cell instead of filtering records
Section 1Finding records with a criterion
A spreadsheet table holds records (rows) made of fields (columns). Often you want only some of them: the cheap items, the low stock, one category. You describe what you want with a criterion. A criterion is a condition that a record must meet. It has three parts: a field, a comparison and a value. In Qty < 10, the field is Qty, the comparison is 'less than' and the value is 10. A filter is a list of conditions that each record must meet to be displayed. Records that meet them are shown. Records that do not are hidden from view, not deleted. Throughout this topic we use a stock list from a school-supplies shop in Mandeville: Notebook, Stationery, 40, 250; Pen box, Stationery, 12, 600; Backpack, Bags, 8, 4500; Ruler, Stationery, 55, 120; Calculator, Electronics, 6, 3800; Lunch bag, Bags, 15, 1800; Headphones, Electronics, 4, 5200; Marker set, Stationery, 9, 950; Flash drive, Electronics, 20, 2200; Pencil case, Bags, 25, 700; Glue stick, Stationery, 30, 180; Mouse, Electronics, 10, 2600. The fields are Item, Category, Qty (the number in stock) and Price (in J$). There are 12 records.
Section 2Simple criteria: one condition
A simple criterion is a single condition. Examples from the stock list: Category = Stationery shows 5 records: Notebook, Pen box, Ruler, Marker set and Glue stick. Qty < 10 shows 4 records: Backpack, Calculator, Headphones and Marker set. Price > 2000 shows 5 records: Backpack, Calculator, Headphones, Flash drive and Mouse. The AutoFilter is the simple method. You choose a value from the drop-down list on a column heading, and only the records with that value are shown. Choosing Electronics in the Category list shows the 4 electronics records. The comparisons are the same ones used in the IF function: = (equal to), <> (not equal to), > (greater than), < (less than), >= (greater than or equal to) and <= (less than or equal to).
Section 3Boundary values
As with IF, the edge of a condition is where marks are lost. Look at Qty in the stock list. The Mouse has exactly 10 in stock. Qty < 10 leaves the Mouse out and shows 4 records. Qty <= 10 includes the Mouse and shows 5 records. The same happens with Price. Pen box costs exactly J$600. Price >= 600 shows 9 records, while Price > 600 shows only 8. Price < 600 shows the other 3: Notebook, Ruler and Glue stick. Watch out: 'at least' and 'or more' mean >=. 'More than' means >. 'Less than' means <, and 'at most' or 'or fewer' means <=.
Section 4Complex criteria: AND and OR
A complex criterion joins two or more conditions. The joining word matters. AND means a record must meet every condition. Category = Electronics AND Qty < 10 shows only the electronics items that are also low in stock: Calculator and Headphones, 2 records. OR means a record needs to meet at least one condition. Category = Bags OR Price > 4000 shows the 3 bags plus the one expensive item that is not a bag (Headphones): Backpack, Lunch bag, Headphones and Pencil case, 4 records. Backpack meets both conditions but is shown once. Here's the trick: AND narrows the search, so it gives the same or fewer records. OR widens it, so it gives the same or more. Swap AND for OR in the first example and the answer grows from 2 to 6. A range uses AND with two conditions on the same field: Price >= 600 AND Price <= 2000 shows 4 records: Pen box, Lunch bag, Marker set and Pencil case.
Section 5Standard filter and advanced filter
The standard filter handles complex criteria. Each condition names a field, a comparison and a value, and the conditions are joined by AND or OR. To use it: select the table, open the filter tool, build each condition, choose AND or OR between them, and confirm. The matching records are shown. The advanced filter does the same job, but it takes its criteria from cells you fill in on the sheet. You type the field name and the condition into cells, and the filter uses them. To see all the records again, clear the filter. Because the other records were only hidden, nothing is lost.
Section 6The Find command
The Find command searches for a term, cell by cell, through the sheet. It highlights or jumps to the cells that contain the term. Find all highlights every matching cell at once. The match case option makes the search care about capital letters. Search the stock list for bag. Without match case it finds 4 cells: the Category cell Bags three times (for Backpack, Lunch bag and Pencil case) and the item cell Lunch bag. With match case on, only Lunch bag matches, because Bags starts with a capital B. That gives 1 cell. Easy to mix up: Find locates cells that contain a term. A filter shows only the records that meet a criterion. If you need a list of all the electronics items, use a filter. If you need to jump to the word Mouse, use Find.
Section 7Working out the result of a criterion
To find which records a criterion picks out, test the records one at a time, in order. For each record, check each condition and write down true or false. For AND, keep the record only if every answer is true. For OR, keep it if at least one is true. Then count the records you kept. Check the count makes sense: an AND result should never be bigger than either condition on its own, and an OR result should never be smaller than either. For Qty < 10 OR Price > 4000, the low-stock items are Backpack, Calculator, Headphones and Marker set. The two items over J$4000, Backpack and Headphones, are already in that list. So the result is 4 records, not 6. Do not add the counts if the same record can meet both conditions. Two conditions that cannot both be true give no records. Category = Bags AND Category = Electronics shows 0, because a record has only one category.
Examples
A school-supplies shop in Mandeville keeps this stock list (item, category, quantity in stock, price in J$): Notebook, Stationery, 40, 250; Pen box, Stationery, 12, 600; Backpack, Bags, 8, 4500; Ruler, Stationery, 55, 120; Calculator, Electronics, 6, 3800; Lunch bag, Bags, 15, 1800; Headphones, Electronics, 4, 5200; Marker set, Stationery, 9, 950; Flash drive, Electronics, 20, 2200; Pencil case, Bags, 25, 700; Glue stick, Stationery, 30, 180; Mouse, Electronics, 10, 2600. (a) An AutoFilter is set on Category to Electronics. State the records shown. (b) A filter is set with the simple criterion Qty < 10. State the records shown. (c) The owner changes the criterion to Qty <= 10. State how many records are shown now, and which record is the extra one.
(a) Pick Electronics from the Category list. Only electronics records are shown: Calculator, Headphones, Flash drive and Mouse. That is 4 records, and the other 8 are hidden. (b) Test the Qty of each record. Qty below 10: Backpack 8, Calculator 6, Headphones 4 and Marker set 9. That is 4 records. (c) Qty <= 10 includes 10 itself. The Mouse has exactly 10, so it joins the list. Now 5 records are shown: Backpack, Calculator, Headphones, Marker set and Mouse. The extra record is the Mouse, and it sits on the boundary value.
Use the same stock list: Notebook, Stationery, 40, 250; Pen box, Stationery, 12, 600; Backpack, Bags, 8, 4500; Ruler, Stationery, 55, 120; Calculator, Electronics, 6, 3800; Lunch bag, Bags, 15, 1800; Headphones, Electronics, 4, 5200; Marker set, Stationery, 9, 950; Flash drive, Electronics, 20, 2200; Pencil case, Bags, 25, 700; Glue stick, Stationery, 30, 180; Mouse, Electronics, 10, 2600. (a) Find the records for the complex criterion Category = Electronics AND Qty < 10. (b) Find the records for the complex criterion Category = Bags OR Price > 4000, listed in the order they appear in the sheet. (c) The owner changes the AND in part (a) to OR. State how many records are shown, and explain why the number grows.
(a) A record must be Electronics and also have Qty below 10. The electronics records are Calculator (6), Headphones (4), Flash drive (20) and Mouse (10). Only Calculator and Headphones have Qty below 10. The answer is 2 records. (b) A record needs to be a bag or cost more than J$4000. The bags are Backpack, Lunch bag and Pencil case. The items over J$4000 are Backpack (4500) and Headphones (5200). Backpack is in both groups but shown once. In sheet order the result is Backpack, Lunch bag, Headphones, Pencil case: 4 records. (c) With OR, a record is shown if it is Electronics or has Qty below 10. The 4 electronics records are shown, and so are the low-stock items that are not electronics: Backpack and Marker set. That is 6 records. OR needs only one condition to be true, so more records qualify than with AND.
Now let's water it
Session runs notes to flashcards to quiz back-to-back.
Where this comes from
- CSEC Information Technology Syllabus (CXC 30/G/SYLL 08, revised 2000, 2008, 2013) · Caribbean Examinations Council (CXC) · Section 7, Specific Objective 12 · Syllabus scope
- Calc Guide 7.6 (LibreOffice 7.6 Community) · The Document Foundation (LibreOffice Documentation Team) · Chapter 2, Filtering, pp 70-71 and 75, checked against (https://documentation.libreoffice.org/assets/Uploads/Documentation/en/CG7.6/CG76-CalcGuide.pdf) · Facts
- Calc Guide 7.6 (LibreOffice 7.6 Community) · The Document Foundation (LibreOffice Documentation Team) · Chapter 2, Find and replace, pp 79-80, checked against (https://documentation.libreoffice.org/assets/Uploads/Documentation/en/CG7.6/CG76-CalcGuide.pdf) · Facts
- Calc Guide 7.6 (LibreOffice 7.6 Community) · The Document Foundation (LibreOffice Documentation Team) · Chapter 8, Comparison operators, p 275, checked against (https://documentation.libreoffice.org/assets/Uploads/Documentation/en/CG7.6/CG76-CalcGuide.pdf) · Facts