6. Tables, Sorting and Filtering
6.6 Advanced Filter
Give an order two ways to qualify
A fictional grocery coordinator wants every order headed to Nashik on an afternoon handoff list. Pune orders should be included only if they were delivered and their amount is above ₹200. That request offers two routes into the same report. A Nashik order can qualify regardless of its amount. A Pune order must satisfy three requirements together. If you use the ordinary City menu to show both cities and separately set Amount and Status, you apply those extra tests to Nashik too. The small Nashik order that the coordinator wanted would disappear.
Advanced Filter lets you write those two routes in cells. Excel checks each source record against the criteria range, which is a small block of worksheet cells containing the test headings and values. A row within that block describes one route. Every filled test on that row must be true for that route to pass. The next row can describe an alternative. Excel can then show the qualifying records in place or copy them into a separate block for review.
The first example uses the same fictional, Blinkit and Amazon Now-inspired order list introduced in Chapter 3. The brand names are familiar examples. The order data, coordinator’s rule and amounts are invented for practice.
Place the source, rules and output separately
Advanced Filter works with physical addresses. The List range is the whole source rectangle including headers. The Criteria range includes condition labels and the specific rule rows you have filled. With a copied extract, Copy to points to an independent destination. The examples use a scratch worksheet where data occupies A1:I11, columns K through M hold conditions, and columns P through S hold output. This layout leaves room between blocks and lets you review their meaning without guessing which header belongs to which area.
- Include the source headers. A record begins below the headings. If list range begins at A2, Excel can treat the first order as part of the labels and fail to find City or Amount. Copy the exact range address from the list as a first check.
- Keep field headings identical. Copy City, Amount and Status directly from the source. Amount (₹), Amount followed by a space and Amount are different labels for this purpose. The field condition should identify a specific known source column. An explicit formula criterion follows a different convention, introduced later.
- Include condition rows deliberately. K1:M3 includes headers and exactly two routes. A wholly empty row inside the selected criteria grid supplies no restrictions, giving every record a route to qualify. Blank cells within a real route allow the other tests on that row to decide. Do not fill future empty rows into the current selection.
- Give output its own space. You can select an empty destination cell to copy all columns, or enter exact destination headings and select that heading block to copy only those fields. Ensure the width and height cannot write over existing records. The labs use nonoverlapping blocks on one scratch tab.
Choose between viewing the original and building an extract
Filter in place is useful if you want to check the source itself. The records that fail are hidden. You can clear filtering to see all records again. With Copy to another location, Excel writes an extract containing the matches. It is an independent output of that run. Editing criteria or input cells later does not automatically replace it. If a teammate is going to reuse it, label the exact rule, include the date or version of the export and explain how to rebuild it.
The exercises use Excel desktop and its Data → Advanced command in the sorting/filtering controls. Choose an Excel desktop client that exposes the dialog. If using a browser version without the command, you can still complete the prediction exercise by evaluating each source record against the rule rows. Then, if your client supports the modern FILTER function, use the optional formula exercise to produce a recalculating result. That formula uses its own conditions and is separate from the Advanced Filter dialog.
Test a whole criteria row at a time
Consider the four-order mini list below. Think of a document clerk marking one source record “eligible” if it passes the criteria they were given. They look at the row for ID 101, check its city, then check its amount. If both conditions occupy the same row, City Pune is only half the required information. ₹100 fails the amount test. With the rules on separate rows, City Pune alone is enough for 101. This is why moving a single condition down a row can change the effect of the whole grid.
| ID | City | Amount | Pune and >200 | Pune or >200 |
|---|---|---|---|---|
| 101 | Pune | 100 | No | Yes |
| 102 | Mumbai | 300 | No | Yes |
| 103 | Pune | 400 | Yes | Yes |
| 104 | Mumbai | 200 | No | No |
- Both conditions on one row. The row has City equal to Pune and Amount greater than 200. Only 103 passes. The result is one ID totaling ₹400.
- Same conditions on separate rows. First row has only City equal to Pune. Second row has only Amount greater than 200. IDs 101, 102 and 103 pass. Their total is ₹800. ID 103 appears once even though it qualifies through both criteria rows.
- Boundary evidence. ID 104 is worth exactly ₹200. It fails greater than and its City is different. If the request includes equality, use greater than or equal to and expect 104 in the alternative-row result.
When the rule grows, mark a short sample with a pass or fail for each route before you set it up. In common spreadsheet terms, AND means all checks in a set have to pass, and OR means one or more is enough. A written rule might contain both. Let each criteria row explain one complete reason for inclusion, even when some words are repeated in more than one condition row.
Write conditions Excel can interpret
Exact names and starting text serve different purposes
In the City criterion, enter ="=Pune" to require the exact text Pune under the regular text-matching rules. This worksheet formula returns the text =Pune into the cell. The Advanced Filter reads the leading equals sign in that returned text as its comparison instruction. Entering =Pune directly would ask Excel to interpret Pune as a defined name or expression. The enclosing quotes in the first expression preserve the text for the criteria operation.
Plain Pune in the criteria block can match places whose text begins with Pune. For example, after you test the original report, add a fictional Pune West order in a scratch copy and set City to the plain text Pune. With no other conditions inside that route, both names can pass. Change the criterion to ="=Pune", rerun it and verify Pune West drops out. This check is valuable whenever a place field contains a city name plus a branch or zone. Standard text criteria are case-insensitive. Case sensitivity is a separate requirement and can be expressed with a logical formula using a function such as EXACT when you truly need to compare capitalization.
- Comparison text for a number. Type
>200under Amount to retain amounts above 200. The source amounts need to be numeric. The cell in the criteria grid expresses the test and may appear as text even though it is testing numbers. - Include a lower or upper boundary explicitly. Decide whether ₹200 or ₹500 can qualify if you describe a band. Test a record equal to an endpoint, and store the exact symbol in the rule grid so it is reviewable.
- Two bounds on the same field. Add a second criterion column with the same Amount header, and place both tests on the same criteria row. Amount >200 and Amount <500 on that row requires each amount to meet both tests. Separate rows would let records pass through either side and could admit almost the whole list.
- Pattern criteria. An asterisk represents a sequence of zero or more characters and a question mark represents one character. A tilde before one of these symbols treats the next symbol literally. Use deliberate patterns rather than using a leading prefix accidentally. For a short dispatch list exact city names are easier to review.
Give a Boolean formula its own heading
Suppose the order lead wants to see rows worth more than the average of the entire list. The amount cutoff depends on the source figures. Excel can evaluate a logical expression for each source record. A Boolean result is TRUE or FALSE. For this kind of criterion choose a heading like Above list average that is absent from the source headers, or follow the documented blank-heading option. Put a formula such as =C2>AVERAGE($C$2:$C$7) underneath when the source begins at row 2 and its amounts are in C. A nonmatching heading tells Excel you are supplying a calculated condition rather than the text or number test for an existing column.
In the formula, C2 is a reference to the first data row. The row part of that reference can change as Excel evaluates later records. $C$2:$C$7 stays fixed. It identifies the common six amounts that define the comparison. If you freeze C2 as well, the same test of the very first amount could decide every row. If you forget to fix the comparison range, a later row might use a moving subset, making the results difficult to explain. The criteria cell itself normally displays a single TRUE or FALSE because its formula is evaluated against the first source row there. Advanced Filter applies the adjusted expression to the remaining records during its run.
Lab 1. Build the Nashik and Pune dispatch extract
In a fresh sheet named Dispatch, type the following practice records into A1:I11. The header row has nine labels. Use numbers for Qty, Amount and Mins. Values in Date are 2 through 8 November 2026 and can be entered using a local date form. These dates are included for continuity with Chapter 3. They do not affect the main filter. Select this exact list inside the dialog so the separate rule and output blocks stay independent.
| Order ID | Date | City | Platform | Category | Qty | Amount | Mins | Status |
|---|---|---|---|---|---|---|---|---|
| BLK-1001 | 2 Nov | Pune | Blinkit | Dairy | 2 | 64 | 9 | Delivered |
| BLK-1002 | 2 Nov | Nashik | Blinkit | Fruits | 3 | 270 | 12 | Delivered |
| AMN-1003 | 3 Nov | Pune | Amazon Now | Snacks | 1 | 110 | 14 | Delivered |
| BLK-1004 | 3 Nov | Nagpur | Blinkit | Fruits | 2 | 240 | 11 | Cancelled |
| AMN-1005 | 4 Nov | Kolhapur | Amazon Now | Dairy | 4 | 232 | 16 | Delivered |
| BLK-1006 | 4 Nov | Pune | Blinkit | Bakery | 5 | 150 | 8 | Delivered |
| BLK-1007 | 5 Nov | Solapur | Blinkit | Home | 1 | 1299 | 18 | Delivered |
| AMN-1008 | 6 Nov | Sambhaji Nagar | Amazon Now | Staples | 3 | 195 | 10 | Returned |
| BLK-1009 | 7 Nov | Pune | Blinkit | Snacks | 2 | 220 | 13 | Cancelled |
| BLK-1010 | 8 Nov | Nashik | Blinkit | Fruits | 1 | 90 | 17 | Delivered |
| City | Amount | Status |
|---|---|---|
="=Pune" | >200 | ="=Delivered" |
="=Nashik" |
Choose your output fields and verify the result
- Enter the field labels Order ID, City, Amount and Status in P1:S1, matching the source headings. There are four output fields. Platform, product category, quantity, timing and date remain in the source where the coordinator can check them later.
- Open Data → Advanced from Dispatch. Select Copy to another location. Enter
$A$1:$I$11as the List range,$K$1:$M$3as Criteria range and$P$1:$S$1as Copy to. Leave Unique records only unchecked. The question asks for each qualifying order, so you want every record that passes. - Read the output. BLK-1002 qualifies because its city is Nashik. BLK-1010 also qualifies through Nashik with ₹90 because that route has no minimum. Expect two matched records, both Delivered in the example, with total ₹360. Nothing in the rule required a Nashik row to say Delivered.
- Trace a near miss. BLK-1009 meets the Pune and amount checks but its status is Cancelled. It fails the Pune row and is not Nashik. BLK-1006 is Delivered in Pune but its amount ₹150 falls short. These examples show which field excluded each record.
- Lower the amount test in L2 to greater than 100. The old output can remain until you run Advanced Filter again. Clear the previous result cells beneath the four headings before rerunning in the same destination. Now AMN-1003 and BLK-1006 qualify through Pune, and both Nashik rows still qualify. Expect four IDs and ₹620. Return L2 to greater than 200, remove the old output rows again and confirm the result returns to two.
Changing the rules while keeping the source unchanged is a useful debugging exercise. A smaller rerun can leave old cells below the new copy if the previous output area is reused without clearing it. The headings and results are normal cells from a separate range. The filter reads the current criteria at the moment you run the command. An old subtotal next to the original copy cannot tell you whether the latest extract was rebuilt.
Follow one source record through the rule grid
Start with BLK-1009
The record is Pune, ₹220 and Cancelled. We need to evaluate each complete rule that can allow it into the extract.
Apply the first criteria row
Pune passes and ₹220 is above ₹200. Cancelled fails the Delivered requirement. The first route fails as a whole.
Try the second criteria row
The order is not Nashik. This route has no amount or status restrictions, but the one required city fails.
Check actual output
BLK-1009 stays out. BLK-1002 and BLK-1010 qualify via the second row. Their combined amount is ₹360.
Build a recalculating copy where FILTER is available
The lab’s output under P1:S1 is a command result. A student who wants a result that updates as values change can write a formula with the same logic. In the Dispatch sheet use an empty block with room for nine columns and potential result rows. Start outside the source, criteria and prior extract. For instance, type the source headers in V1:AD1 and enter the formula in V2:
=FILTER(A2:I11,((C2:C11="Pune")*(G2:G11>200)*(I2:I11="Delivered")+(C2:C11="Nashik"))>0,"No matching orders")
Each comparison makes ten TRUE or FALSE answers, one per source record. Multiplying the three Pune conditions converts each one to one or zero, so their product is one only when all three are true. Adding the Nashik result counts how many routes pass. Greater than zero means at least one route passed. The output contains all nine columns for the same two source orders. Leave enough empty cells for the output to expand, a behavior Excel calls spilling. The fallback message appears if there are no matches. If your installation uses semicolons between formula arguments, use the separator your Excel expects.
The numeric cutoff in this formula is a literal 200. Editing the Advanced Filter text in L2 changes the documented rule grid, and the formula reads its own 200. Change the formula’s 200 to 100 to test the wider view, or set a separate numeric parameter cell and refer to it explicitly. Avoid pointing a numeric comparison to the text >200 from the command’s criteria block: that cell stores a comparison instruction, while the formula needs a numeric cutoff. To verify the optional formula, compare the order ID columns in the two outputs after setting the same rule and rerunning the command. Formulas aimed at A2:I11 also need an updated source when there are more than ten records, unless you use a verified dynamic reference.
Lab 2. Use one shared average and extract distinct areas
On a fresh sheet named Konkan, enter the following six orders in A1:C7. Use the exact header Amount for this copy of the exercise. The fictional Konkan Fresh Mart uses a separate local grocery scenario inspired by the kinds of small orders a shopper could place through Blinkit. Dates are unnecessary for this lab. The mean needs all six amounts even when your filtered view shows only three.
| Order ID | Area | Amount |
|---|---|---|
| KFM-601 | Baner | 650 |
| KFM-602 | Kothrud | 320 |
| KFM-603 | Baner | 420 |
| KFM-604 | Wakad | 900 |
| KFM-605 | Kothrud | 780 |
| KFM-606 | Baner | 910 |
Predict the first formula test and the full result
- Use a check tab to calculate the full amount and average. Sum is ₹3,980. Divide by 6 to get ₹663 and one third. You can verify with
=AVERAGE(Konkan!C2:C7). Keep the test’s comparison precise even if a number format displays only two decimals. ₹663.33 is a display approximation. - In Konkan E1 enter the new heading Above list average. In E2 enter
=C2>AVERAGE($C$2:$C$7). The worksheet cell displays FALSE because the first record has only ₹650. The expression still selects later records whose amounts exceed the same list average. - Run Data → Advanced. Supply
$A$1:$C$7as List range,$E$1:$E$2as Criteria range and use Copy to another location with$H$1as an empty destination. Keep the source, criteria and copy areas uncrowded. Expect KFM-604, KFM-605 and KFM-606, whose three amounts add to ₹2,590. Check the complete rows in H2:J4 against the source IDs and amounts. - Now add Area to F1 and
="=Baner"to F2. Include$E$1:$F$2as the criteria range and rerun after clearing the copied data or moving it to a fresh block. Only KFM-606 matches. KFM-601 is Baner but below the comparison amount. KFM-604 and 605 satisfy the formula but have other areas. The formula and area test are a single two-part route. - Try a rule with two number bounds. In L1:M1 put Amount in both headings. In L2 put
>=650and in M2 put<900. Run the same source through$L$1:$M$2with an empty destination at O1. Verify KFM-601 and 605, totaling ₹1,430. The ₹650 endpoint is included and the ₹900 endpoint is excluded.
Check what you are asking Excel to treat as a duplicate
Still on Konkan, run Advanced Filter again. Use $B$1:$B$7 as List range with its Area header. Leave Criteria range empty and choose Copy to another location with a fresh output such as $T$1. Tick Unique records only. Check that the three area values are Baner, Kothrud and Wakad. Verify their membership rather than relying on a particular sort order. The source area field still has six filled entries. Each repeated area may describe a different order, so it is valid to have six entries in the master list.
Compare with Advanced Filter using the whole List range $A$1:$C$7, no criteria and Unique records only, copied into another empty block. There are six different IDs, so all six complete rows are distinct. This exercise distinguishes distinct area names from distinct order records. To report a number like “three delivery areas,” select the Area field as the list. To report a number like “six orders,” retain the IDs and verify their uniqueness at the record level. A duplicate report can support an investigation without modifying source records.
Diagnose failures with a hand-checked test case
Start with the rule and work back to the coordinates
- Too many records. Check for an included empty criteria row, a prefix that matched wider names, or an amount and city rule on separate rows. For the four-row grid, count the difference between the expected one AND match and three OR matches. That exercise gives you a known pattern to compare against a large workbook.
- No records or an invalid reference. Verify that the source address contains the heading row, that the criteria address includes the exact heading, and that the numeric and date columns are stored using their intended types. Every filled ordinary criterion should point to a known source heading. Make sure the destination block does not overlap either input block.
- The copied result shows old records. Make sure you ran the command after the last criteria edit. Use an empty destination or clear the previous result below the destination headings first. On the new copy, compare the exact expected IDs, row count and amount total. Checking just the top row would miss older rows below it.
- A formula seems to decide all records the same way. Look at its first-record reference. Under the new heading,
C2should refer to the first actual amount. Keep the range inside AVERAGE fixed. Try the formula against one amount just below and another above the average to check that the result can go both ways. - The report unexpectedly lost columns. Review the heading range you passed in Copy to. A block labeled Order ID, City, Amount and Status deliberately requests four columns from a nine-column list. To extract all fields, select an empty destination with enough width or list all required labels.
- The sheet already has a filtered view. In a copy, clear ordinary filters before starting the example. Record which conditions the Advanced Filter uses. Reconcile the result to the original source range and your expected route logic. This keeps an old visual restriction from disguising your test.
Try a short practice with Konkan that recovers the basic route from the previous AutoFilter lesson. Under Area and Amount place ="=Baner" and >500 on the same condition row. Under this put ="=Kothrud" in Area and leave Amount empty on that second rule row. The four matches are KFM-601, KFM-602, KFM-605 and KFM-606, totaling ₹2,660. Then run the first rule alone and expect only KFM-601 and KFM-606, at ₹1,560. This rehearsal strengthens the habit of verifying a full rule before adding alternatives.
Carry a shared requirement into each alternative
A common change request is “We now want only delivered orders in both cities. In Pune, check that amount is above ₹100 as well.” The date, source columns and method of copying can stay the same. The criteria need one additional filled cell because the existing Nashik route never had a status test. Change the first route to Pune, above ₹100 and Delivered. Change the second route to Nashik and Delivered with Amount empty. The extra field on row 3 makes the shared delivery requirement visible.
Test the case that exposes the difference
- With the original source, both routes combined give four records. You might see that very same output if the second row were still missing its Status rule. Both Nashik records happen to be Delivered already, so the original list gives no way to distinguish the two rule designs by inspecting that result alone.
- In the scratch source, change BLK-1010 to Returned while leaving its city and amount untouched. Under the loose rule, the order keeps qualifying because Nashik is the only condition in the second row. You will still see AMN-1003, BLK-1002, BLK-1006 and BLK-1010. Together they represent ₹620 regardless of the last order’s status.
- With Delivered entered under Status in both criteria rows, rerun into a cleared destination. BLK-1010 now fails its own route and is removed. BLK-1002, AMN-1003 and BLK-1006 pass and their amount total is ₹530. You can verify that ₹620 minus the missing ₹90 equals this result.
- Set the original BLK-1010 status back to Delivered before using the earlier lesson checks. Keep the rows of criteria you want to reuse in a clearly marked practice area, or record the final grid elsewhere before resetting the exercise.
One successful example can hide a rule error when all tested rows happen to have the same status. An example differing in precisely the field under discussion makes the check far stronger. That controlled change is called a test case: you set one example up so the correct design and a plausible wrong design produce different outputs. An order placed exactly at ₹100 would be a second useful test case, since “above ₹100” excludes equality.
Keep the record key when handing off selected columns
The amount alone cannot identify which order a teammate should inspect. Preserve Order ID in the extract so the receiver can go from one report row to its source record. If a team needs a copy on a separate tab, a straightforward beginner workflow is to run Advanced Filter into the known safe block in the exercise, then copy the verified output rectangle to a separate scratch tab. Compare the headers and IDs there as well. This makes the input and output choices visible and keeps the full dispatch list available for corrections later.
For example, let the receiving tab start at A1 with Order ID, City, Amount and Status as its four headers. Check that each amount stays aligned with its identifier and that a lookup for BLK-1010 would lead back to its record, even if the two output rows later get sorted. Keep a small note of when you produced the copy, because a status correction to the original order can make an older open extract misleading.
Quiz. Read the criteria before running the command
Where do the Pune and Delivered conditions belong if both are required?
They belong on the same criteria row, under the exact columns City and Status. Excel treats one row as a set of requirements. Putting them on separate criteria rows would allow a Delivered order in any city, and it would also allow Pune orders with a different status.
Which four-row practice IDs match City Pune or Amount above 200?
101 passes City, 102 passes Amount and 103 passes both. Use a separate criteria row for each route. ID 104 is Mumbai and worth exactly 200, so it fails both and does not appear. The three matching amounts add to ₹800.
Why is blank Amount beside Nashik valid?
That particular route requires only the city. An empty cell within a filled criteria row leaves the field unrestricted. A completely empty row included in the selected rule block can allow every record. The route still needs at least one condition if you intend it to restrict the source.
The amount criteria say greater than 100 now. Why does the extract still contain two orders?
Advanced Filter performed a copy using the previous criteria. Rerun the command after changing the criteria, and start with an empty output area below the headers. Verify four orders with total ₹620 when the 100 cutoff is active.
Which name criterion keeps Pune West out of the result?
Use the formula ="=Pune" under the City criteria heading. The result of the formula includes the equals comparison character, so the Advanced Filter checks the whole label instead of a prefix. Verify that the source records use the intended stored city names.
Can a formula criterion showing FALSE in E2 still select records?
Yes. E2 tests the first source record at its current reference and displays FALSE because that record’s ₹650 is below the list average. The Advanced Filter then tests other records with their own amounts and the same comparison base. The amounts ₹900, ₹780 and ₹910 exceed that base.
Interview practice. Explain the output and its limits
When would you use Advanced Filter after learning AutoFilter?
Use the worksheet grid when you need separate groups of AND conditions connected by OR and want those rules visible for review. The Nashik route has no amount condition, so ordinary Amount and City header menus would combine the tests incorrectly. A helper column or a FILTER formula can also express the logic. Pick a documented grid when colleagues need to rerun it manually and review its exact criteria.
How can you justify results to someone who cannot open the spreadsheet?
State each route in words and trace an included and an excluded ID through it. For example, BLK-1010 is Nashik and passes independently of its ₹90 amount. BLK-1009 is in Pune with enough amount but a Cancelled status and fails both routes. Then report two IDs and a ₹360 check amount under those exact criteria.
How do you select amounts between two bounds with an OR alternative?
Repeat the Amount heading in two criterion columns and put the lower and upper test in the same row. The source amount must pass both of those comparisons. Put the alternative as a separate complete route beneath it. Verify a record at each endpoint and one satisfying the alternative alone.
How do you distinguish distinct areas from duplicate order rows?
Set List range to the Area column for a distinct-area report and tick Unique records only. Konkan then yields three names. When the full Order ID, Area and Amount range is selected, the six different IDs make every full record distinct. The unique result answers a different question because you changed what a record contains for the command.
How would you ensure a small extract can be safely refreshed?
Record the exact source, criteria and destination addresses and keep them from overlapping. Before rerunning, clear old result cells under the destination headings or choose a clean block. Then confirm the new record count and IDs using hand-checked examples. Keep the full source intact so later reviewers can inspect both passing and failing rows.
Revision cards
- Source. Include the heading row and every intended data row. Keep the criteria and output cells beyond the source boundary.
- Across. Conditions on one criteria row all need to be true.
- Down. Separate criteria rows are alternative routes. One complete match is enough.
- Exact text. The expression
="=Pune"supplies an equality instruction against the complete City label. - Boolean formula. Use a heading outside the source labels. Test the first data row with a relative reference and fix the comparison range.
- Copy snapshot. Run the command again when rules change. Clear prior result cells and verify the output IDs.