How to use And and Or operators with Excel's Advanced Filter (2023)

by Susan Harkins in Software

on

How to use And and Or operators with Excel’s Advanced Filter

Use implicit And and Or operators with Excel's Advanced Filter feature to create complex, but powerful, filtering combos.

Editor’s Note: This article was originally published in July 2010 and the video tutorial for this article published Dec. 2018; while this program might look a little different, the steps shown in this tutorial are the same.

Viewing subsets of data is a routine task for many Excel users. An AutoFilter lets you limit the data displayed, but it’s limited as it depends on the actual data. Excel’s Advanced Filter feature requires a bit of setup, but is more flexible and powerful than an AutoFilter. Not only can you use an expression to match records, you can combine expressions using the And and Or operators – now, that’s power!

This blog post is also available as a TechRepublic Photo Gallery.

Excel’s Advanced Filter feature requires three elements:

  • Data
  • A criteria range, where you specify criteria as an expression.
  • An extract range, where Excel displays the data that satisfies the criteria.

LEARN MORE: Office 365 Consumer pricing and features

A simple AutoFilter

Before we get into a more advanced example, let’s look at a simple AutoFilter example using a partial set of data from the Products table from Northwind (the database that comes with Access). To apply an AutoFilter, you select the column headings in A1:F1 and choose AutoFilter from the Data menu. In Excel 2007 and 2010, click the Data menu and then click Filter in the Sort & Filter group. Excel will display a dropdown arrow for each column in the selection. Using this feature, you can perform simple filtering tasks, such as which products have no units on order. It’s quick and easy, but sometimes inadequate. (To remove a filter, simply choose All from the same list.)

An Advanced Filter and And

Now, suppose you wanted to know which products with a price of $20 or more have 10 or less units currently in stock. This filtering task has two requirements – two criteria – and you want to satisfy them both. In other words, the product must be $20 or more and have 10 or fewer units in stock. An AutoFilter just can’t do that, so let’s try an Advanced Filter.

The criteria range, in this case, requires only two columns: Unit Price and Units In Stock. You could copy just those column headings to an out of the way place. I recommend copying all of the headers – you might need them for another filter.

SEE: Crash Course: Microsoft Excel – Beginner (Tech Pro Research)

Next, you need to state your filtering requirements in terms Excel can understand, using an expression. In this case, both expressions are simple comparisons:

Unit Price: >=20

Units In Stock: <=10

As you can see, the criteria range is above the actual data. This placement is efficient and easily accessible. Both expressions are in the same row – row 2. By placing both expressions in the same row, Excel knows to apply an implicit And operator to combine the expressions.

All that’s left now is to apply the filter as follows:

  1. Click any cell in the data range.
  2. Click the Data menu, and then click Filter | Advanced Filter. In Excel 2007 and 2010, click the Data tab and then click Advanced Filter in the Sort & Filter group.
  3. Retain the default setting, Filter the List In-Place.
  4. Excel automatically fills in the List Range, correctly in this case.
  5. Specify the Criteria range, A1:F2. You only need to identify the column headings and the criteria row or rows.How to use And and Or operators with Excel's Advanced Filter (2)
  6. Click OK.

Eight products have a price of $20 or more and have 10 or fewer units in stock. To remove the filter, click the Data menu, then click Filter | Show All.

An Advanced Filter and Or

To specify an implicit Or operator, you must place the expressions in separate rows. The criteria shown below will find products with a price of $20 or more or products with 10 or fewer products in stock.

After adjusting the criteria range by moving one of the expressions down a row, apply the new filter as follows:

  1. Click any cell in the data range.
  2. Click the Data menu, and then click Filter | Advanced Filter. In Excel 2007 and 2010, click the Data tab and then click Advanced Filter.
  3. Retain the Filter the List In Place setting, the default.
  4. Excel automatically fills in the List Range, correctly in this case.
  5. Specify the Criteria range–that’s A1:F3. Notice that this time, the range includes row 3.How to use And and Or operators with Excel's Advanced Filter (3)
  6. Click OK. Many records meet one or the other criteria.How to use And and Or operators with Excel's Advanced Filter (4)

You can use an Advanced Filter with just one expression, but using implicit And and Or operators opens the door for some very complex but powerful filters. Just be careful that the expressions and their placement make sense, in terms of applying the And and Or operators.

Affiliate disclosure: TechRepublic may earn a commission from the products and services featured on this page.

How to use And and Or operators with Excel's Advanced Filter (5)

Daily Tech Insider Newsletter

Stay up to date on the latest in technology with Daily Tech Insider. We bring you news on industry-leading companies, products, and people, as well as highlighted articles, downloads, and top resources. You’ll receive primers on hot tech topics that will help you stay ahead of the game.

Delivered Weekdays

Sign up today

Also See

By Susan Harkins

Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.

  • Account Information

    Contact Susan Harkins

  • |
  • See all of Susan's content
  • Microsoft
  • Software

Editor's Picks

  • TechRepublic Premium

    TechRepublic Premium editorial calendar: IT policies, checklists, toolkits and research for download

    TechRepublic Premium content helps you solve your toughest IT issues and jump-start your career or next project.

  • Payroll

    The best human resources payroll software of 2023

    With a lot of choices in the market, we have highlighted the top six HR and payroll software options for 2023.

  • Software

    Windows 11 update brings Bing Chat into the taskbar

    Microsoft's latest Windows 11 allows enterprises to control some of these new features, which also include Notepad, iPhone and Android news.

  • CXO

    Tech jobs: No rush back to the office for software developers as salaries reach $180,000

    Salaries for remote roles in software development were higher than location-bound jobs in 2022, Hired finds.

  • Software

    The 10 best agile project management software for 2023

    With so many agile project management software tools available, it can be overwhelming to find the best fit for you. We've compiled a list of 10 tools you can use to take advantage of agile within your organization.

  • Security

    1Password is looking to a password-free future. Here’s why

    With phishing-based credentials theft on the rise, 1Password CPO Steve Won explains why the endgame is to 'eliminate’ passwords entirely.

How to use And and Or operators with Excel's Advanced Filter (13)

Daily Tech Insider Newsletter

Stay up to date on the latest in technology with Daily Tech Insider. We bring you news on industry-leading companies, products, and people, as well as highlighted articles, downloads, and top resources. You’ll receive primers on hot tech topics that will help you stay ahead of the game.

Delivered Weekdays

Sign up today
Top Articles
Latest Posts
Article information

Author: Duncan Muller

Last Updated: 03/01/2023

Views: 6183

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.