Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query AND Operator: Combine Filters in Excel

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The AND operator in Power Query is the keyword and, and you use it to join two or more conditions so a row is kept only when every condition is true at the same time. You need Power Query in Excel, Power BI Desktop, or the Power Query add-in in Power BI, a table or file to load, and a basic filter step to edit. Case matters: write and, or, and not in lowercase, because Power Query treats those as functions and a capitalised And is read as text.

What You'll Need

  • Excel with Power Query (Data > Get Data) or Power BI Desktop; in Power BI the same steps live in Transform Data.
  • A table or range with at least two columns to filter on.
  • Some rows with values that are borderline, so you can see the filter working.
  • Awareness that menu labels differ slightly between versions, editions and regions.

Step-by-Step

  1. Load your data: in Excel, select the table, then choose Data > Get Data > From Other Sources > From Table/Range. In Power BI, choose Home > Transform Data to open the Power Query Editor. The editor window is where every formula below is built.
  2. Click the filter arrow on the first column you want to filter and pick a value. This adds a step to the Applied Steps list on the right and writes a formula in the formula bar, something like = Table.SelectRows(Source, each ([Status] = "Open")).
  3. Look at the formula bar. The each keyword starts a condition, and [Status] is a field reference. This is the part you edit to add an AND.
  4. Add the second filter: click the filter arrow on the second column and choose its value. Power Query adds a second step. That works, but it produces two Table.SelectRows steps and the logic becomes hard to read.
  5. Merge them into one condition. In the formula bar, delete the second step by right-clicking it in Applied Steps and choosing Delete. Then edit the first step to read = Table.SelectRows(Source, each ([Status] = "Open" and [Amount] > 100)). Both conditions sit inside the same pair of parentheses, joined by the lowercase word and.
  6. Press Enter. The step now filters on both conditions at once and the row count in the status bar drops to the matching rows.
  7. Add a third condition the same way: each ([Status] = "Open" and [Amount] > 100 and [Region] = "West"). Each extra and narrows the result further.
  8. For text, wrap the value in double quotes; for numbers, leave them bare. For dates, use #date(2026, 1, 31) style literals or the date picker so the type matches the column.
  9. Use or only when you want either condition: each ([Status] = "Open" or [Status] = "Pending") keeps rows matching either one. Mixing them needs brackets, for example each (([Status] = "Open" or [Status] = "Pending") and [Amount] > 100). Power Query evaluates the bracketed part first.
  10. Close and load with Home > Close & Load. The filtered table lands back in Excel or as a new table in Power BI.

Common Mistakes

The most frequent error is writing And with a capital letter. Power Query is case-sensitive for keywords, so And is treated as a text value and the step fails with a formula syntax error. Use lowercase and.

A second mistake is a single equals sign where two are needed. Comparison uses =, but some users carrying habits from other languages write ==, which is not valid in Power Query. When comparing text, the quotes must match the column type; comparing a text column to a number silently returns no rows rather than an error.

Stacking filter steps instead of combining them makes the query slower and harder to debug, because later steps narrow the data and the Applied Steps list grows. One Table.SelectRows with a combined condition is easier to audit. Also check for a column name mismatch: [Amount] fails if the column is actually called Amount (USD), and spaces or punctuation must be inside the brackets.

Finally, watch operator precedence. Without brackets, a and b or c is read as (a and b) or c, which may keep more rows than intended. Bracket any mixed expression.

Tips

Keep the condition readable by pressing Shift+Enter inside the formula bar to break it across lines; Power Query ignores line breaks. Give the step a clear name in Applied Steps (right-click > Rename) so you can tell it apart from a dozen sibling filters.

Use not for exclusions instead of listing every allowed value: each not [Status] = "Closed". Nulls are a common trap, because [Status] = null returns null, not true. Test with [Status] <> null and [Status] = "Open" when your data has blanks. You can also filter nulls straight from the column menu (Remove Empty) to avoid surprises.

If you need a between range, write it explicitly: each [Amount] >= 100 and [Amount] <= 500. Power Query has no between keyword.

Troubleshooting

If the editor shows Token Comma expected or Token Eof expected, count the parentheses and brackets. Every each expression needs matching brackets, and field names need square brackets. A missing closing parenthesis at the end of a long condition is the usual culprit.

If every row vanishes, check the comparison types. Text "100" will not equal number 100. Right-click the column header and use Change Type before filtering, or convert the value in the expression. If some rows appear missing that look correct, look for trailing spaces; use Text.Trim in a transform step.

If the step fails only after refresh, the source data has changed type or gained a renamed column. Open the step and confirm the column names still exist. Click the error notice on the row for the exact reason.

Frequently Asked Questions

Is AND the same as "&&" in Power Query?

No. Use the word and, not &&, which is not valid Power Query code.

Can I use AND inside a custom column?

Yes. In Add Column > Custom Column, write something like if [Amount] > 100 and [Status] = "Open" then "High" else "Low".

Why does my AND filter return blank instead of rows?

One of the compared values is probably null. Power Query comparisons involving null produce null, which is treated as false. Filter out nulls first.

What is the difference between and, or, and not?

and requires both conditions, or requires one, and not inverts a condition. All three are lowercase.

Do the filters match uppercase and lowercase?

Text comparison in Power Query is case-sensitive by default in many comparisons, so "open" and "Open" may not match. Standardise the case with Text.Lower or Text.Proper first.