keepcalculator

06 Numbers and Powers

Filter and Exclude Columns: How-To Guide

Card No. 06·50784 · Updated · Standard formula, shown below

Average pace 5.00 min/km
Average speed
12.00 km/h
Result
Finish time
50 min
You entered
Distance
10 km
You entered
You enter
Finish time, Distance
You get
Average pace, Average speed
Rounding
2 dp

Filtering and excluding columns lets you hide or remove specific data fields from a table, report, or dataset without deleting the underlying data. You typically filter columns to focus on relevant information, and exclude them to prevent them from being processed or displayed. This guide covers how to do both in common tools like Excel, Google Sheets, SQL, and Python, plus when to use each approach.

What Does Filtering a Column Mean?

Filtering a column means temporarily hiding rows that don’t meet a condition you set for that column. For example, in a sales spreadsheet, you might filter the “Region” column to show only “West” rows. The data is still there, but the view is narrowed. Filtering is non-destructive and reversible — you can clear the filter anytime.

Column filtering is different from column exclusion. Filtering affects rows based on a column’s values; excluding a column removes the entire column from view or processing. You might filter to see only high-value customers, but exclude the “Notes” column because it’s too long or irrelevant.

How to Filter Columns in Excel and Google Sheets

Both Excel and Google Sheets have built-in filter tools. The steps are nearly identical:

  • Select the header row or any cell in your data range.
  • Go to the Data menu and choose “Filter” (Excel) or “Create a filter” (Google Sheets).
  • Click the dropdown arrow that appears in each column header.
  • Uncheck values you want to hide, or use “Text filters” / “Number filters” for custom conditions.
  • To remove the filter, click the funnel icon again and choose “Clear filter” or press Ctrl+Shift+L (Windows) / Cmd+Shift+L (Mac).

For more complex filtering, use the “Advanced Filter” in Excel (Data > Advanced) to filter based on criteria in a separate range. In Google Sheets, you can use the FILTER function: =FILTER(A2:D100, B2:B100="West") returns only rows where column B equals “West”.

How to Exclude Columns in Excel and Google Sheets

Excluding columns means hiding them from view or omitting them from calculations. The simplest way is to hide the column:

  • Right-click the column letter (e.g., “C”) and choose “Hide”.
  • To unhide, select columns on both sides, right-click, and choose “Unhide”.

For excluding columns from a formula, use a range that skips them. For example, to sum columns A and C but not B, use =SUM(A:A, C:C). In Google Sheets, the QUERY function lets you select specific columns: =QUERY(A:D, "select A, C, D") returns only those columns.

Filtering and Excluding Columns in SQL

In SQL, filtering columns is done with the SELECT statement — you choose which columns to include. Excluding a column simply means not listing it in the SELECT clause. For example:

SELECT name, email FROM customers;

This excludes the “phone” and “address” columns. To filter rows based on a column’s values, use WHERE:

SELECT name, email FROM customers WHERE signup_date > '2023-01-01';

You can also create a view that excludes columns permanently for a specific user or application:

CREATE VIEW customer_contacts AS SELECT name, email FROM customers;

Remember that SQL is set-based: you always specify what you want, not what you don’t want. There’s no “EXCLUDE COLUMN” keyword, but you can achieve the same result by listing only the columns you need.

Filtering and Excluding Columns in Python (Pandas)

In Python’s Pandas library, filtering columns is straightforward. To select specific columns, use:

import pandas as pd
df = pd.read_csv("data.csv")
df[['name', 'email']]  # keeps only these columns

To exclude columns, use the drop method:

df.drop(columns=['phone', 'address'], inplace=True)

Filtering rows based on a column’s values uses boolean indexing:

df[df['signup_date'] > '2023-01-01']

This keeps all columns but only rows where the condition is true. You can combine both: select specific columns and filter rows in one step.

Choosing Between Filtering and Excluding

The choice depends on your goal:

  • Filtering is best when you want to analyze a subset of rows while keeping all columns available for context.
  • Excluding is best when a column is irrelevant, too large, or contains sensitive data you don’t want to see or share.
  • If you’re building a report for others, excluding columns that aren’t needed reduces clutter and improves readability.
  • If you’re exploring data, filtering lets you drill down without losing any information.

You can also combine both: filter rows to a relevant subset, then exclude columns that aren’t needed for that particular view.

Common Mistakes and Pitfalls

Here are frequent errors people make when filtering or excluding columns:

  • Filtering only the visible range — if you don’t select the entire dataset, some rows won’t be filtered. Always select the full data range or use a table (Excel) / named range.
  • Forgetting to clear filters — a hidden filter can make data appear missing. Check the funnel icon for a filter indicator.
  • Excluding columns in formulas — if you hide a column, formulas that reference it still work, but if you delete it, formulas break. Use caution with direct references.
  • Mixing up row filters and column filters — in Excel, “filter” always refers to rows. To hide columns, you must hide them manually or use a view.
  • In SQL, forgetting that SELECT * includes all columns — always list columns explicitly to avoid accidentally including sensitive data.

Frequently Asked Questions

Can I filter multiple columns at once?

Yes. In Excel and Google Sheets, you can apply filters to multiple columns simultaneously; the filters combine with AND logic (rows must meet all conditions). In SQL, you use multiple conditions in the WHERE clause with AND/OR. In Pandas, you combine conditions with & (and) or | (or), remembering to wrap each condition in parentheses.

Does filtering delete my data?

No. Filtering only hides rows temporarily. The data remains in the sheet or table. To permanently remove rows, you must delete them manually or use a function that returns a new dataset without those rows (like SQL DELETE or Pandas drop with inplace=True).

How do I exclude a column from a pivot table?

In Excel, you can’t exclude a column from a pivot table directly — you choose which fields to add to Rows, Columns, Values, and Filters. Simply don’t add the field you want to exclude. In Google Sheets, the pivot table editor lets you add only the fields you need.

What’s the difference between hiding and excluding a column?

Hiding a column in a spreadsheet just makes it invisible; the data is still there and can be used in formulas. Excluding usually means removing it from a query, report, or export. In SQL, “exclude” means not selecting it; in Pandas, it means dropping it from the DataFrame.

Can I filter columns in a CSV file without opening it?

Yes. You can use command-line tools like awk or cut to extract specific columns, or use a script in Python, R, or another language. For example, cut -d, -f1,3 file.csv keeps only the first and third columns.

Why does my filter not work on some columns?

This usually happens when the column contains mixed data types (numbers and text), blank cells, or merged cells. Ensure all cells in the column have the same data type, and avoid merging header cells. In Excel, convert your data range to a Table (Ctrl+T) to make filtering more reliable.

Related

Formula used
in t | Finish time | min | 50 | 0
in d | Distance | km | 10 | 0 | 100000
out pace | Average pace | min/km | t / d | 2
out speed | Average speed | km/h | d / (t / 60) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →