9.2 FILTER
Return the orders that satisfy a worksheet rule
A group running an imaginary delivery workshop wants a live report of delivered Pune orders. The complete source includes several other cities, and one Pune order is cancelled. Their first report needs only order ID, date and amount. They want to choose another city without copying and pasting a new list. Excel’s FILTER function can put a new list in a separate clear area by testing one inclusion rule per source row.
Use the examples as practice only. The first lab follows the fictional ten-order source used earlier in the course, inspired by shopping examples from Blinkit and Amazon Now. The second is a four-order sample where you can see every TRUE or FALSE result. The full inputs and quantities are invented. The site also has a short FILTER guide for reviewing the basic syntax after the exercises.
Read the three arguments in the order Excel needs them
In FILTER(array,include,[if_empty]), the first input supplies the rows or columns that could be returned. The second input is a Boolean list of decisions, meaning tests whose results are TRUE or FALSE or values that can be interpreted that way. The third parameter, when supplied, describes what to display when no result matches. Square brackets in the syntax description mean an optional argument. You do not type extra brackets around the optional message.
Think of include as one test per record
For an input of ten records and five fields, a row-based filter needs a vertical test list with ten decisions. The first decision applies to the first source record, the second to the second record and so on. If the filter instead selects columns, the include input can be a horizontal list with one test for each input column. In both cases the test must align with its intended source. A vertical list of the right height but shifted one record is still wrong.
- Choose output fields. A five-column input can return the fields from all five columns. A three-column input returns only those three when rows are matched.
- Choose matching rows. Give the second argument a row-by-row expression. For example, compare every value in the City data column with the city setting in B2.
- Choose an empty state. An explicit message like No matching orders is useful for a reader checking the list. With no results and no fallback, the worksheet can show
#CALC!because Excel does not return an empty array in this case. - Prepare the destination. Enter the formula once outside the input Table. Leave room for the maximum result. Put other notes and criteria out of the rectangular output.
Combine two tests while preserving row-by-row decisions
A test that compares the City column with Pune produces one answer for every source row. A second comparison to Delivered tests the same rows in their own Status field. Multiply the per-row results to express AND. TRUE then works like 1 and FALSE like 0. A row with any false condition has a product of zero. The rows with both true produce 1. For each order, read the pair of facts before reading the product.
For an OR rule, add the two Boolean results and explicitly test whether the sum is above zero. A row may satisfy neither rule, either rule or both. The sums are 0, 1 and 2. Turning those back into TRUE or FALSE avoids treating the number 2 as two rows. FILTER still visits the record once. An AND() or OR() wrapped around entire range comparisons usually produces a single aggregate TRUE/FALSE decision rather than the per-row test list required here. Keep each comparison parenthesized and verify the dimensions of the combined result.
Plan a separate count for a no-match message
A fallback such as “No matching orders” helps a human understand what happened. It should not appear as a record in later statistics. Even a displayed one-cell area can represent zero actual matches. Count the conditions on the source, for example using COUNTIFS for a conjunction over clean data. If you use one label and number in a report, make the count the evidence for the factual state and the label the explanation.
Lab 1. Build a city selector and a three-field report
In your practice workbook use an Orders sheet for source entries and a Delivery Report sheet for the result. Arrange the original ten orders as below. The report fields Order ID, Date and Amount sit next to each other, so the FILTER input can name their consecutive Table span. Use numeric dates and amounts. The status and category fields remain available to the source even though the main report does not show them.
| Order ID | Date | Amount | City | Status | Category | Mins |
|---|---|---|---|---|---|---|
| BLK-1001 | 2 Nov | 64 | Pune | Delivered | Dairy | 9 |
| BLK-1002 | 2 Nov | 270 | Nashik | Delivered | Fruits | 12 |
| AMN-1003 | 3 Nov | 110 | Pune | Delivered | Snacks | 14 |
| BLK-1004 | 3 Nov | 240 | Nagpur | Cancelled | Fruits | 11 |
| AMN-1005 | 4 Nov | 232 | Kolhapur | Delivered | Dairy | 16 |
| BLK-1006 | 4 Nov | 150 | Pune | Delivered | Bakery | 8 |
| BLK-1007 | 5 Nov | 1299 | Solapur | Delivered | Home | 18 |
| AMN-1008 | 6 Nov | 195 | Sambhaji Nagar | Returned | Staples | 10 |
| BLK-1009 | 7 Nov | 220 | Pune | Cancelled | Snacks | 13 |
| BLK-1010 | 8 Nov | 90 | Nashik | Delivered | Fruits | 17 |
Give the reader just one setting to change
- Create the real source. Convert A1:G11 to a Table with headers and name it
tblFilterwhere possible. If a name is unavailable, use the assigned Table name throughout. Use proper Excel dates, for example=DATE(2026,11,2)formatted as a date, rather than assuming a day-month string will parse in every locale. - Build a City setting. In Delivery Report, put City in A2 and Pune in B2. On a client with Data Validation, put six source city names and the intentional test choice Delhi into J2:J8 with no blank cells. Select B2, choose Data Validation with Allow set to List, and give it source
=$J$2:$J$8. Set in-cell dropdown if that option appears. This list is explicitly maintained. Type choices directly into B2 if the control is unavailable. - Make room for the returned fields. Put Order ID, Date and Amount in A5:C5. The result anchor is A6. Leave space below all three output columns for Table growth. Format the report’s Date column as a date so a returned numeric date is readable. Report formatting and the date’s stored value are separate.
- Enter the filter formula once. Paste the formula below into A6. Check the shape and confirm the same exact dates and amounts remain with their IDs. FILTER does not change source order.
=FILTER(tblFilter[[Order ID]:[Amount]],(tblFilter[City]=$B$2)*(tblFilter[Status]="Delivered"),"No matching orders")
In B3 put =COUNTIFS(tblFilter[City],$B$2,tblFilter[Status],"Delivered") and label A3 Matching orders. In the Pune view there should be three records and ₹324 total. The row order is BLK-1001 at ₹64 on November 2, AMN-1003 at ₹110 on November 3 and BLK-1006 at ₹150 on November 4. That means a three-row, three-column result. A three-row count that includes the wrong ID is not enough to verify the report. BLK-1009 is a useful counterexample because it is in Pune but was cancelled.
Test the filter with a smaller result, a larger source and no match
- Choose Nashik in B2. BLK-1002 and BLK-1010 remain, totaling ₹360. Check the dates 2 and 8 November. Choose Delhi and expect the A6 message and a count of zero in B3.
- Choose Pune again. On Orders append BLK-1101, 9 November 2026, 180, Pune, Delivered, Bakery, 14. Confirm the new record actually joined the Table. Now the report shows four rows, including the new ID at the end because no separate sort was requested. The amount becomes ₹504.
- Change just that new record’s status to Pending in the scratch copy. The source still has eleven records and the report returns to three. Restore Delivered before continuing. Check that both the dropdown choice and the formula source remain intact after testing an edit.
Test the report’s four result states
Choose Pune
Three delivered orders are returned. Their amounts add to ₹324. The cancelled Pune order is excluded.
Change to Nashik
Two delivered orders qualify and their amount is ₹360. The data source remains unchanged.
Test an unlisted source city
Delhi exists in the dropdown for testing. No matching orders appears and Matching orders reads zero.
Append a qualifying Pune record
After selecting Pune again, a verified Table member with Delivered at ₹180 makes four returned records and ₹504.
Lab 2. Test overlapping rules and invalid input
In a separate sheet called Criteria type these four practice rows, including column headings in A1:D1. This is the compact source introduced in the chapter overview. It has overlapping conditions on purpose. Because each row is short, you can evaluate the correct result by hand before entering the formulas.
| Order | City | Platform | Amount |
|---|---|---|---|
| O101 | Pune | Blinkit | 100 |
| O102 | Mumbai | Amazon Now | 300 |
| O103 | Pune | Amazon Now | 200 |
| O104 | Pune | Blinkit | 400 |
Check the output of a conjunction and a disjunction
In F2 enter =FILTER(A2:D5,(B2:B5="Pune")*(D2:D5>150),"No matching orders"). Leave F2:I5 available. Only O103 and O104 qualify. The ₹100 Pune order fails the amount test. The Mumbai order at ₹300 fails City. The two output amounts add to ₹600. This is a conjunction, a rule that requires all stated tests to pass together.
In K2 enter =FILTER(A2:D5,((C2:C5="Blinkit")+(D2:D5>250))>0,"No matching orders"). The four raw scores in source order are 1, 1, 0 and 2. Checking them against zero gives TRUE, TRUE, FALSE and TRUE. The output contains O101, O102 and O104, totaling ₹800. O104 scores 2 because it satisfies both tests, and it appears once because the filter makes a single inclusion decision per record. This is a disjunction, a rule in which either condition can be enough.
You can check the OR count on a separate line using =SUMPRODUCT(--(((C2:C5="Blinkit")+(D2:D5>250))>0)). The two minus signs convert final TRUE/FALSE decisions to 1 and 0. The count is 3. Adding the raw scores without the last comparison gives 4, which is the number of satisfied tests across the four records, not the number of retained records. The test with an overlapping row makes the difference visible.
Use a horizontal condition to choose fields
In a different clear area such as F10:H15, enter =FILTER(A2:D5,A1:D1<>"Platform","No fields"). The four comparisons run across the source headings, so they filter columns. The selected fields are Order, City and Amount, and the result keeps all four input rows. It has four rows and three columns. The output headings can be entered separately above it. When the shape is wrong, read whether you supplied one decision per column or one decision per row.
Distinguish an include error from zero matches
Now purposely set O102’s Amount to =NA() in D3. The conjunction formula tests whether that amount is above 150, which now raises an error. The City test may be false for O102, but multiplying by FALSE does not prevent Excel from encountering the invalid value. Microsoft documents that an error inside FILTER’s include argument can make the filter return an error. The third argument handles a genuine no-match state; it does not repair an invalid comparison.
For an approved provisional view that should exclude invalid or missing amount entries, verify the types and replace the intended per-row test with a safe test. In a new clear area or at the original F2 anchor after preserving its initial formula, try:
=FILTER(A2:D5,IFERROR((B2:B5="Pune")*ISNUMBER(D2:D5)*(D2:D5>150),FALSE),"No matching valid orders")
This formula asks the same two business questions and requires a numeric amount. IFERROR changes a failing comparison into FALSE for that row. The result still includes O103 and O104 at ₹600. Record the missing source amount separately. For example, =ROWS(D2:D5)-COUNT(D2:D5) gives one nonnumeric amount cell in this controlled source. Inspect the ID O102 to distinguish a formula error from text or a blank. The label must say you excluded invalid value inputs. Keep the unmodified source and correct the data when it becomes available.
Restore O102’s numeric amount 300 and verify both the conjunction and the OR output from before. Change the city test temporarily to Delhi with the original clean data to see a genuine no-match message. This is distinct from an incorrect formula that stops at an error. Keep both controlled cases available in notes so you can tell which problem you are seeing in another worksheet.
Pick different output fields without changing which records qualify
Filter on a timing column outside the output
Return to the original ten-order Table or use a separate clean copy. In a clear worksheet area try =FILTER(tblFilter[[Order ID]:[Amount]],tblFilter[Mins]>15,"No matching orders"). The include values ask whether the timing is above fifteen minutes. The formula returns Order ID, Date and Amount. The result comes from the three orders AMN-1005, BLK-1007 and BLK-1010 at ₹232, ₹1,299 and ₹90, for a total of ₹1,621. Mins still drives the selection even though the output does not display it. Check the input timing for an included and excluded ID to document why they differ.
Do not infer that an adjacent span always consists of only two endpoint fields. In the example tblFilter[[Order ID]:[Amount]] also includes Date because it sits between those headings. This is useful in the planned layout. On a workbook whose exact desired fields are not adjacent, use a supported projection such as CHOOSECOLS before filtering or arrange a controlled input view. If a newer client supports it, CHOOSECOLS(tblFilter,1,7,3) selects Order ID, Mins and Amount in this fixture. Use it as the first FILTER input with the original aligned Mins test. The result still contains the same three rows, and the changed headings tell the reader that the middle value is minutes.
Choose a category pattern on purpose
To return source rows whose Category contains Fruit, try =FILTER(tblFilter[[Order ID]:[Amount]],ISNUMBER(SEARCH("Fruit",tblFilter[Category])),"No fruit-category orders"). SEARCH returns a character position when it finds the text, and a value error when it finds no match. ISNUMBER turns the numeric positions into TRUE and other results into FALSE. The three practice rows are BLK-1002, BLK-1004 and BLK-1010, totaling ₹600. Because this request has only a category condition, the cancelled fruit order is allowed. To show delivered fruit orders, multiply the category test by the Delivered test and expect ₹360 from the other two.
An exact comparison to the singular word Fruit matches none of the original Category entries, which say Fruits. A comparison to Fruits matches those three entries in the clean practice source. A contains search can also match longer labels, such as “Dried Fruit,” in a real category list. Ask which kind of match should define the report before replacing one condition with another. SEARCH is case-insensitive and its pattern can use wildcard characters. Validate the user text and compare one exact and one partial match before making a business claim based on the search output.
Catch a shifted include list with the same dimensions
In the small Criteria lab, make sure B6 is genuinely blank. In a separate error-test area try the conjunction with the City test accidentally set to B3:B6 while Amount remains D2:D5. The include comparisons still have four rows. They are simply aligned to different records. O102 gets the City test from the next row, which is Pune, and enters incorrectly. O104 gets a test from the empty row 6 and disappears. The wrong list contains O102 and O103, totaling ₹500. The correct list is O103 and O104 at ₹600.
A dimension check alone would not catch this error. Compare IDs and verify each test input belongs to the same record. Structured Table fields taken from the same data body help by keeping that context. A formula can still refer to another Table or a shifted output accidentally, so read the first and last field references together. If the wrong result looks plausible, add a known response for one row that fails only a single condition.
Extend the worksheet report with a fixed date window
Open a saved copy with the ten original orders before the append. A fictional delivery review asks for delivered orders from 3 through 5 November 2026. A person may think the date test only requires one comparison because the report describes a single period. The formula needs two boundaries. In the report’s clear area put the inclusive start date in B10 and the first day outside the period in B11. Use =DATE(2026,11,3) and =DATE(2026,11,6) to set those dates. Label B11 “End date excluded” so the next user can read the intended rule.
Enter the formula in a clear region far enough from the previous result. For example, use F10:H25 with the field labels in F9:H9. The date boundaries in B10 and B11 remain outside the result. Use the same three-field projection as in Lab 1:
=FILTER(tblFilter[[Order ID]:[Amount]],
(tblFilter[Date]>=$B$10)*(tblFilter[Date]<$B$11)*(tblFilter[Status]="Delivered"),
"No delivered orders in the window")
Check exactly which date and state excluded each row
- 2 November. BLK-1001 and BLK-1002 are delivered. Both fail the inclusive start date because it starts the next day. The status flag cannot make them pass the date window.
- 3 November. AMN-1003 passes with ₹110. BLK-1004 is in the window and fails because it was cancelled. This pair distinguishes a date-only report from its requested delivered-only scope.
- 4 and 5 November. AMN-1005, BLK-1006 and BLK-1007 pass. Their total is ₹1,681. Together with the first passing row the result has four records at ₹1,791.
- 6 November and later. These rows are outside the date window even if their status qualifies. BLK-1010 is Delivered on 8 November and remains excluded.
If you remove the Delivered condition, you gain only BLK-1004 at ₹240 and the date-only result becomes five records at ₹2,031. A separate COUNTIFS check can use the same date boundaries, one as “greater than or equal to” and the other as “less than,” plus Delivered. Keep numeric dates in those setting cells and avoid relying on ambiguous text, such as a label without a year. An independent count is useful when you change the dates and a perfectly valid empty state becomes possible.
One reason for using a first-excluded day is that order records can contain clock times. If BLK-1007 is revised from 5 November at midnight to 5 November at 6:00 p.m., it is still earlier than 6 November at midnight and stays included. A formula using “at or before 5 November at midnight” would leave it out. A Date number format can hide the time while preserving its stored value. Compare dates using the intended business window and keep the output’s format clear enough for its readers.
Verify the report layout before expanding the source
Place the second result away from the first formula’s possible growth. A separate sheet is another option if both results can reach many rows. The report anchored at A6 grows based on City. This date report grows based on a time window. The two decisions can both add several rows during the same source update. A clear initial layout does not guarantee that both reports are safe if their eventual output rectangles can overlap. In the F10:H25 layout above, the tables use separate columns from the first report’s A:C, and the settings stay outside both outputs.
Count matching records before summarizing a filtered result
Consider a version of the compact four-order sheet where the request is “Pune or amount above 200.” Evaluate each order under both tests. O101 and O103 pass because they are Pune, O102 passes because it is above 200 and O104 passes both. There are four included records. Do not add the count of Pune rows, which is three, to the count of amounts above 200, which is two, without accounting for their overlap. The result would be five despite only four source records. Build the Boolean test once and use its normalized true values for the count.
One way to calculate just the total amount for that same view is to return the Amount field instead of the whole order grid and sum it. For example:
=SUM(FILTER(D2:D5,((B2:B5="Pune")+(D2:D5>200))>0,0))
With the original clean sample it returns ₹1,000. The inner fallback is numeric 0 because the outer goal is a sum. This formula produces one value even though FILTER can return several amounts to SUM. An order count is still separate. For a confirmed zero case, change the City test to Delhi and raise the amount limit to over 500. The same four records now match neither rule, so the sum is zero and a consistent count is zero. A real list could also have a matching record with an actual amount of zero. A zero subtotal by itself cannot tell you which case occurred.
Confirm the overlap in the larger source before publishing a total
Run a related comparison for the original ten Table records: City is Pune or Amount is above ₹200. The Pune subset has four orders and totals ₹544. The strictly above-200 subset has five orders and totals ₹2,261. BLK-1009 at ₹220 appears in both subsets. With the combined OR there are eight distinct included records, and the overlap contributes only once. Compute the total independently by adding ₹544 and ₹2,261 and subtracting ₹220, which gives ₹2,585. Compare the ID membership as well. AMN-1008 and BLK-1010 are the excluded orders. Their amounts ₹195 and ₹90 add to ₹285, which equals the original source total ₹2,870 minus ₹2,585.
If you meant Pune and amount above ₹200 instead, only BLK-1009 passes. The result is ₹220. This one-record test makes the difference between multiplying the two Boolean tests and adding them visible. Use both versions in a scratch copy and name each output with the actual rule. Check that an order which qualifies by City only is in the OR result and absent from the AND result. Source-wide tests can reveal mistakes that a small list with no overlap would miss.
When reporting a rule someone requested in ordinary language, write the parentheses in your notes. “Pune and Delivered, or anything above ₹200” can intentionally mean two routes, one of which allows other statuses. If the intention is instead “Delivered and either Pune or above ₹200,” apply the status check to the full combined result. In the original ten records the first reading includes five large orders and three Pune deliveries, for eight records and ₹2,585. The second reading excludes both large cancelled records, leaving six records at ₹2,125. This difference identifies why parentheses belong in the design as well as the formula. Check a qualifying cancelled order from each city if you need to prove exactly which interpretation the copied report used.
Use a known result that makes an input error obvious
In a clean copy set O101’s amount to a genuine numeric 0. A two-test query for Pune and “amount at least zero” should include O101. Replace that value with an empty cell and compare the intended rule. Excel can coerce a blank to zero in some expressions. In this workbook the business rule says there must be a numeric amount, so include ISNUMBER(D2:D5) as a separate aligned condition. The numeric zero then qualifies and the empty cell does not. The two cases may look alike in a spilled output if blank source values appear as zero. Use the original input type as evidence rather than deducing it from displayed figures.
For a report that should retain an order even when its amount is unavailable, leave the amount out of the inclusion test and define a separate missing-value display or status field. The source can then show the order’s existence while indicating that its amount is missing. That is a different requirement from the provisional valid-amount view in Lab 2. Agree on which records the report should keep before hiding an input error. If the next operation must calculate a money total from available values, document how that smaller numeric population differs from the displayed order count.
Test an input table with no qualifying members without confusing it with a blocked formula
A user moving the anchor may place it where the old output does not fit. They could see the expected no-match message for Delhi, then switch to Pune and see a spill error. The empty state needed just one cell. Pune needs three rows and three columns in the original delivery report. Check the visible spill border and identify any old note or merge inside that footprint. Repair the layout without changing the rule. Then verify both city settings again. A small empty-case test is helpful, and it cannot replace the positive-case layout check.
Follow the source, condition and result in that order
- No matching orders. Check that the chosen city and status exist together. A valid city in the dropdown can still have no matching delivered order. Use a clean count of the same criteria to establish whether the fallback is correct.
- A number looks right but compares unexpectedly. Check whether the source stored a number, text digits or an error. Validate or repair the practice amount. If approved, use a per-row numeric test and keep a count of excluded invalid entries.
- The formula reports a spill error. Check the output footprint before changing the criteria. A new city can return more matching rows than the previous one and need cells that were previously free.
- Count stays small after appending. Verify the new record’s named Table membership, exact stored category or status and all value cutoffs. The filter can correctly omit an appended row that fails a condition.
- A returned cell cannot be edited directly. Click the formula anchor and check the formula bar. Dynamically returned cells are controlled by the anchor. Edit the input or expression there rather than pasting into individual result cells.
- A linked result stops recalculating. Check the source workbook. Dynamic array links have limited support when both files are open. Use a verified local source or a validated static extract if the report must work without the other workbook.
You can use FILTER as something other than the final worksheet output. If you place an amount projection inside SUM, for example, the final expression can return one number. Check whether the inner no-match fallback is compatible with the outer function and whether the reader needs a separate count. A phrase like “No matching orders” is helpful on a worksheet but should not be mistaken for a numeric amount. A zero total can also describe one or more legitimate measured values. Label the corresponding record count so the two outcomes can be distinguished.
Quiz. Predict the included records
Which original Pune rows are delivered?
BLK-1001, AMN-1003 and BLK-1006. BLK-1009 fails the status test. The included amounts are 64, 110 and 150, totaling ₹324.
What does the include expression’s 2 mean in an OR test?
The row satisfies two tests, and it still appears once. Compare the score with zero before counting matches so the overlap does not inflate a record count.
Can you filter on Mins while returning only Order ID, Date and Amount?
Yes. The include test uses a field that is aligned to the record rows. The return array can display a different subset of fields. In this exercise three rows exceed fifteen minutes.
What does the third FILTER argument do when no rows match?
It supplies the requested fallback, such as No matching orders. It does not create a record. Use an independent count to represent zero matches.
What happens if an amount in a comparison produces an error?
If the error is in the include array, FILTER can return an error instead of a list. Create a controlled valid-input policy or repair the source. The no-match fallback is a separate case.
How can you filter columns instead of rows?
Give FILTER one horizontal decision per source column. In the lab a comparison of the four headings excludes Platform. All four records remain, with three returned fields.
Interview practice. Explain your checks to a reviewer
How would you validate the result before building a live report?
Use a small known source and test one passing row, one failure per condition, an overlap for OR cases and a no-match case. Confirm exact IDs, output dimensions and amounts. Then verify a newly appended Table member follows the same rule.
Why is an aligned include array more than an array with the right number of rows?
The decisions need to refer to the same records in the same order. The shifted City example has the correct height but tests the wrong IDs. Check field sources and row order as well as dimensions.
What is the difference between worksheet FILTER and a Table header filter?
The worksheet formula produces a separate result and can read control cells. The header filter changes which source rows are visible in the same Table. Choose according to whether you need a derived report or a working view of the existing records.
How would you explain a blank result to somebody using the report?
Show a meaningful empty-state message and independently confirm that zero records match the clean condition. If values are missing or invalid, label that separately with a count or affected IDs so it is clear whether the result is truly empty or incomplete.
What type of check catches a returned date formatted as a serial number?
Verify the stored date in the source, then apply Date formatting in the output. Confirm the expected calendar date and order ID together. Position or display style alone does not tell you whether the correct record passed.
Revision cards
- Return array. Choose the rows and columns the report could show.
- Include array. Align one decision to each intended source row or column.
- AND. Multiply two per-record Boolean conditions to require both.
- OR. Add the conditions and test above zero to count overlaps once.
- Empty state. Return a useful message and keep the count of actual matches separate.
- Data quality. Treat invalid inputs explicitly and preserve evidence when some records are excluded provisionally.
Microsoft references
Continue practising: explore the existing Excel Task Hub for additional exercises.