To apply multiple filters in Power Query, you stack filter steps on columns or use the filter dropdowns with text, number, or date conditions. The key is that each filter is a separate step in the Applied Steps list, and they combine with AND logic by default. You can also use the Advanced filter option or write a custom M formula for OR logic or complex conditions. This guide walks through the practical methods, from simple column filters to custom formulas, and covers common pitfalls like filter order and data type mismatches.
What You'll Need
- Power Query available in Excel (Data > Get & Transform Data) or Power BI Desktop (Home > Transform data). The steps are nearly identical; menu labels may differ slightly by version or region.
- A dataset loaded into the Power Query Editor. You can use any table or connect to a source.
- Basic familiarity with the Applied Steps pane and the formula bar.
Step-by-Step
- Load your data into Power Query. In Excel, select your table and go to Data > From Table/Range. In Power BI, use Home > Transform data to open the editor. The data appears in the main pane.
- Apply your first filter. Click the filter arrow on a column header. Choose a condition (e.g., Text Filters > Equals, or Number Filters > Greater Than). Set the value and click OK. A new step appears in Applied Steps, such as "Filtered Rows".
- Apply a second filter on the same or another column. Click the filter arrow on another column and set a condition. Power Query adds another step. By default, filters combine with AND logic: rows must meet all conditions to remain.
- Use the Advanced filter for multiple conditions on one column. Click the filter arrow, choose Text Filters > Advanced Filter (or the equivalent for your data type). Here you can set up to two conditions with AND/OR logic. For more than two conditions, use a custom column or M formula.
- Combine filters with OR logic using a custom column. Go to Add Column > Custom Column. Write an M expression like
[Column1] = "A" or [Column2] > 10. Then filter the new column to keep only true values. This lets you apply OR across different columns. - Edit or remove a filter step. In Applied Steps, click the gear icon next to a filter step to change its condition. To remove, click the X next to the step. Be aware that removing a step may affect later steps that depend on it.
- Reorder steps if needed. Drag steps in Applied Steps to change the order. Filtering early can improve performance, but ensure the data types are correct before filtering.
- Check the result and load. Verify the row count and preview. When satisfied, click Close & Load (Excel) or Close & Apply (Power BI) to load the filtered data.
Common Mistakes
- Filtering before changing data types. If a column is text but contains numbers, numeric filters may not work as expected. Always set the correct data type first.
- Assuming filters combine with OR. By default, multiple filters are ANDed. To get OR logic, you need a custom column or advanced filter.
- Forgetting that filters are case-sensitive in some contexts. Text filters may be case-sensitive depending on the source. Use Text.Lower or Text.Upper in a custom column if needed.
- Ignoring step order. A filter that references a column removed by a later step will cause errors. Keep steps logical.
- Using the wrong filter type. For dates, use Date Filters to avoid text-based comparisons that can fail across locales.
Tips
- Name your steps meaningfully: right-click a step and choose Rename to make the query easier to maintain.
- Use the formula bar to see the M code behind each filter; you can copy and adapt it for complex conditions.
- For repeated filters, consider creating a custom function or using parameters to avoid hardcoding values.
- Test filters on a small sample first to confirm logic before applying to large datasets.
- Keep filters close to the source when possible; filtering early reduces data volume for subsequent steps.
Troubleshooting
If a filter step produces an error, check the data type of the column. A common fix is to change the type to Text or Number as appropriate. If the filter returns no rows, verify the condition values and case sensitivity. If the filter step is greyed out, the column may have been removed by a previous step; reorder or adjust earlier steps. If you see "Expression.Error", the M formula may have a syntax issue; use the formula bar to inspect and correct it. For performance issues with large datasets, try filtering before merging or sorting. If steps are slow, consider using Table.SelectRows with a simpler condition or reducing columns first.
Frequently Asked Questions
Can I apply multiple filters on the same column?
Yes, but each filter is a separate step. For more than two conditions, use the Advanced filter (up to two) or a custom column with an M expression.
How do I combine filters with OR logic?
Use Add Column > Custom Column with an M expression like [Col1] = "X" or [Col2] = "Y", then filter that column to true. Alternatively, use the Advanced filter for two conditions on one column.
Why does my filter not show all expected rows?
Check for leading/trailing spaces, case sensitivity, and data type mismatches. Also ensure no earlier step has already removed rows.
Can I filter by a list of values?
Yes. In the filter dropdown, uncheck "Select All" and tick the specific values. For long lists, use a custom column with List.Contains.
Do filters in Power Query affect the original data?
No. Power Query filters only the query output; the source data remains unchanged. You can always remove steps to restore.
How do I filter dates between two values?
Use Date Filters > Between. Set the start and end dates. Ensure the column is typed as Date, not Text.