top of page

You are learning Sorting and Filtering in MS Excel

How to filter data based on a formula in Excel?

Here are two methods to filter data based on a formula in Excel:

Method 1: Using Advanced Filter with Criteria Range

1. Prepare your data table: Ensure your data has headers in the first row.
2. Create a criteria range: In a separate area of your worksheet, create a table with two rows.
- The first row should contain headers matching your data table's column names.
- The second row will hold your formula. Enter the desired formula in the cell corresponding to the column you want to filter by. For example, if you want to filter for rows where the value in column B is greater than 10, your formula would be `=B1>10` (assuming B1 is your header cell).
3. Select your data range: Highlight the entire table you want to filter, including the header row.
4. Go to Advanced Filter: Navigate to the "Data" tab and click "Advanced" within the "Sort & Filter" group.
5. Copy criteria range: In the "Criteria range" box of the "Advanced Filter" window, click the collapse button and then select the entire criteria range you created (including headers).
6. Copy output range (optional): If you want the filtered data to appear in a separate location, specify the destination range in the "Copy to" box. Otherwise, leave it blank to filter the data in place.
7. Check "Copy only unique records" (optional): This option will prevent duplicates in your filtered results.
8. Click OK: Click "OK" to apply the filter based on your formula.

Method 2: Using FILTER function (Excel 365 only)

1. Prepare your data table: Similar to method 1, ensure your data has headers.
2. Build the FILTER formula: In a separate cell, enter the `FILTER` function.
- The first argument is the data range you want to filter (including headers).
- The second argument is an array created using your formula. Copy the formula from your criteria range (created in method 1) into the FILTER function.
- Note: The formula in the FILTER function needs to be adjusted to work within an array context. For example, if your original formula was `=B1>10`, it would become `B1>10` within the FILTER function (without the equal sign).
3. Optional arguments: FILTER offers additional arguments for handling empty results or custom formatting. You can find details about these in Excel help documentation.
4. Press Ctrl+Shift+Enter (important): Since FILTER is a dynamic array function, pressing Ctrl+Shift+Enter (instead of just Enter) is crucial to create the filter output.

Both methods will filter your data based on the formula you created. Choose the method that best suits your Excel version and workflow.

bottom of page