Smart Systems for Home

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

Power Query Table.FilterWithDataTable: How to Use It

· 6 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

Table.FilterWithDataTable is a Power Query M function that filters a table using a separate table of filter values, returning only the rows where a chosen column matches any value in that filter table. It is the clean, scalable alternative to a hardcoded list in a filter step: instead of typing values into a query, you point the function at a table (in Excel, Power BI, or another query) and the filter updates automatically when that table changes.

Before you start, you need two things: a source table to filter, and a separate table containing the filter values (one column, one value per row). Both should be loaded or referenced in Power Query. The function is not exposed as a button in the Power Query Editor ribbon; you will write it in the formula bar or the Advanced Editor, so a basic comfort with M code helps.

What You'll Need

  • Power Query available in Excel (Data > Get & Transform Data) or Power BI Desktop (Transform data).
  • A source table or query to filter.
  • A filter table with a single column of values to match against.
  • Both tables loaded into the same Power Query environment (as queries or as tables in the workbook).
  • The exact column name in the source table that you want to filter on.

Step-by-Step

  1. Load the filter table. In Excel, format your list of filter values as an Excel Table (select the range, then Insert > Table) and give it a clear name such as FilterList. In Power BI, you can create a small table directly in Power Query or import it. Make sure the column has a header, for example CustomerID.
  2. Load the filter table into Power Query. In Excel, select the filter table, then Data > From Table/Range. This opens the Power Query Editor with a new query. Rename the query to something like FilterValues. Do not load this query to the worksheet if you do not need it there; you can set it to connection only later.
  3. Load the source table. Bring in the table you want to filter (Data > From Table/Range, or from your database/file source). Rename that query, for example SalesData.
  4. Confirm the column names. In both queries, check that the column you will match on has exactly the same name and data type. If the source column is CustomerID and the filter column is Customer ID (with a space), rename one so they match. Data type mismatches (text vs number) will cause the filter to return nothing.
  5. Open the source query and add a step. Select the SalesData query. In the formula bar, you will see the current step. You can either add a custom step via the Advanced Editor or use the formula bar to wrap the existing step.
  6. Write the function call. The syntax is Table.FilterWithDataTable(sourceTable, filterTable, "ColumnName"). For example: Table.FilterWithDataTable(SalesData, FilterValues, "CustomerID"). The first argument is the table to filter, the second is the table of allowed values, and the third is the name of the column in the source table to match on.
  7. Apply the step. If using the Advanced Editor, replace the last step with something like Filtered = Table.FilterWithDataTable(PreviousStep, FilterValues, "CustomerID") and then close the editor. If using the formula bar, you can add a new step by typing the expression after the in keyword, but the Advanced Editor is usually clearer.
  8. Check the result. The query should now show only rows where the CustomerID appears in the FilterValues table. If you see an error, check the column name spelling and that both queries are loaded.
  9. Load the result. Close & Load the filtered query to a worksheet or the data model. The filter table can remain as a connection-only query so it does not clutter your workbook.
  10. Update the filter list. When you add or remove values in the FilterList table, just refresh the filtered query (Data > Refresh All in Excel, or Refresh in Power BI). The filter updates automatically.

Common Mistakes

  • Mismatched column names. The third argument must match the source table's column name exactly, including case and spaces. A typo produces an error or an empty result.
  • Data type mismatch. If the source column is numeric but the filter table column is text, no rows will match. Set both to the same type in Power Query.
  • Using the wrong table order. The first argument is the table to filter, the second is the filter table. Swapping them returns unexpected results or errors.
  • Filter table not loaded. If the filter query is not loaded or is disabled, the function cannot reference it. Ensure it is enabled and named correctly.
  • Duplicate values in the filter table. Duplicates are harmless for filtering, but they can confuse you when checking results. Deduplicate if needed.
  • Assuming it works like a search. Table.FilterWithDataTable matches exact values, not partial text. For partial matches, use Text.Contains with Table.SelectRows instead.

Tips

  • Keep the filter table in a dedicated worksheet or query so it is easy to update.
  • Use connection-only for the filter query to avoid loading an extra table to your worksheet.
  • If you need to filter on multiple columns, apply the function once per column or combine filter values into a single key column first.
  • For large filter lists, this function is much faster than a long OR condition in Table.SelectRows.
  • Name your queries clearly (SourceData, FilterValues, FilteredData) so the M code reads well.

Troubleshooting

If the step returns an error saying the column was not found, open the source query and copy the exact column header. If the result is empty, check data types and confirm the filter table actually contains the values you expect. If the function is not recognized, ensure you are using a recent version of Power Query; the function has been available for several years but very old versions may not include it. If refreshing fails, verify that the filter table query is still enabled and that its name has not changed. When in doubt, step through the query one step at a time using the Applied Steps pane and preview each result.

Frequently Asked Questions

Can I use Table.FilterWithDataTable with a column from another query?

Yes, as long as that query is loaded and enabled in the same Power Query environment. The filter table can be any query that returns a single column of values.

Does it support wildcards or partial matches?

No. It performs an exact match against the values in the filter table. For partial matches, use Table.SelectRows with Text.Contains.

What happens if the filter table is empty?

The result will be an empty table, because no values match. Add at least one value to the filter table and refresh.

Can I filter on more than one column at once?

Not directly with a single call. Apply the function once per column, or create a composite key column in both tables and filter on that.

Is this function available in Excel and Power BI?

Yes, it is part of the standard Power Query M library and works in both Excel and Power BI Desktop. Menu labels may differ slightly between versions.

Do I need to load the filter table to a worksheet?

No. You can set the filter query to connection-only so it stays in the background and does not appear as a table in your workbook.