Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Performing Calculations while Filtering.

Performing Calculations while Filtering

Written by Allen Wyatt (last updated September 17, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

Filtering a list means displaying only a part of it. You provide the criteria you want used, and then Excel displays only those list records that match the criteria. Filtering is especially useful if you have a large list and you want to work with only a subset of the records in the list. Other ExcelTips have described different ways you can create and apply filters to your worksheets.

When you are using the advanced filtering capabilities of Excel you can perform calculations during the filtering process. For instance, let's assume you have a large inventory list in a worksheet, and you want to filter the list to show only those records that were in a particular department and that have a higher-than-average profit. The inventory is contained in starts at cell A6 (with your column headings) and the profit is listed in column I. (See Figure 1.)

Figure 1. Example inventory data in a worksheet.

You can use an advanced filter by setting up your criteria in other cells. For instance, let's say that your criteria are in the cell range A1:B2. (See Figure 2.)

Figure 2. Example filtering criteria.

Row 1 contains the names of the columns in your datasheet that you want compared in the filtering. Thus, cell A1 contains the name "Item" because you want the value under it (in cell A2) to be used in filtering the data table based on the contents of the Item column. There is no column name in cell B1 because you aren't keying the criteria on a column's contents; you want it based on a calculation. Here are the formulas you should place in cells A2 and B2:

Cell Formula
A2 ="W2*"
B2 =I7>AVERAGE($I$7:$I$42)

This example provides for a text comparison related to the department number (in cell A2) and a comparison of the profit for the item (I7, which is a relative cell reference and therefore changes for each comparison) to the average profit for the entire inventory ($I$7:$I$42, which is an absolute reference and therefore does not change for each comparison). If an absolute reference had not been used for the AVERAGE function, the wrong results would have been generated by the filtering.

When you apply an advanced filter to your inventory data (as described in other ExcelTips), the result, using the above criteria, is that only those records that had a profit greater than the average (the average in I7:I42) were displayed.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11630) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Performing Calculations while Filtering.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Disabling Printer Notifications

Do you see a notification balloon pop up from your System Tray whenever you print a document? If this bothers you, then ...

Discover More

Working with Other People's Files

When you get files from other people, you may want a quick way to apply your formatting to their text. Provided that the ...

Discover More

Positioning a Column on the Screen

If you have static columns and dynamic columns on the screen, you may want the dynamic columns to always show a ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Filtering Columns

The filtering tools provided in Excel make it easy to filter a data list so that only certain rows are displayed. What if ...

Discover More

Not All Rows are Filtered

When you are working with large amounts of data in a worksheet, filtering that data can make the process much simpler. ...

Discover More

Skipping Rows when Filling

Using the fill handle is a great way to quickly fill a range of cells with values. Sometimes, however, the way to fill ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four minus 0?

2022-09-17 11:10:09

J. Woolley

Consider use of AutoFIlter instead.
See https://excelribbon.tips.net/T006612_Using_AutoFiltering.html


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.