Power Query Problems

How to Use Power Query to Filter and Copy Data Based on Two Columns

Elise WilliamsElise Williams Nov 3, 2026 869 views

Question details

The user needs to use Power Query to filter rows by a specific level, match values between two columns (such as Number and ParentNumber), and output the selected data into a new worksheet that automatically updates when the source CSV is replaced.

How to Use Power Query to Filter and Copy Data Based on Two Columns
Product
Excel
Device & OS
not provided
Scenario
Automating the process of extracting, filtering, and merging CSV data based on hierarchical or relational columns.
Observed behavior
The user wants a streamlined query that successfully matches rows using an Inner Join, cleans up unwanted columns, and remains fully refreshable.
Before you start

Ensure your source CSV file is saved in a stable, accessible folder. Moving or renaming this file later will break the Power Query connection unless you update the data source settings.

Solution 1Recommended

Filter and Merge Columns using Power Query

Import the CSV, filter the base criteria, and merge the query with the original table using an Inner Join to extract matched rows.

This method involves loading the CSV data twice (or referencing the initial query) so you can compare the base level data against the parent-child relational columns.

Using an Inner Join ensures that only rows with exact matches across both columns are kept in the final output.

1
Import the CSV File into Power Query

Navigate to the Data tab on your ribbon. Click 'Get Data' > 'From File' > 'From Text/CSV'. Select your source file and click 'Import', then select 'Transform Data' to open the Power Query Editor.

2
Create a Filtered Reference Query

In the Power Query Editor, filter the 'Level' column to display only 'Level 0' values. Right-click this query in the left Queries pane and choose 'Reference'. This creates a new query linked to your filtered data.

3
Merge the Queries

With the new query selected, go to the Home tab and click 'Merge Queries'. In the dialog box, select the original source query from the dropdown. Click the 'Number' column in the top table, and the 'ParentNumber' column in the bottom table.

4
Apply Inner Join and Expand

Under 'Join Kind', select 'Inner (only matching rows)' and click OK. Click the expand icon (two arrows) at the top of the newly created merged column. Choose the specific fields you want to load into your final sheet.

5
Clean Up and Load Data

Remove any unnecessary columns by right-clicking their headers and selecting 'Remove'. Finally, click 'Close & Load' on the Home tab to export the matched data into a new worksheet.

Filter and Merge Columns using Power Query
Refreshing Your Data: When you replace the source CSV file with new data, simply open the Excel file, go to the Data tab, and click 'Refresh All'. As long as the file name, location, and column structure are identical, the worksheet will update automatically.
Free Microsoft Office alternative

Need a Fast, Lightweight Tool for Daily Data Tasks?

While complex Power Query integrations are native to Microsoft Excel, WPS Office Spreadsheets offers an incredibly fast and lightweight alternative for standard data filtering, PivotTables, and day-to-day spreadsheet management without a hefty subscription fee.

100% compatible with Microsoft Excel formats (.xlsx, .csv, .xls)Lightning-fast installation and smooth spreadsheet performanceBuilt-in advanced filtering, VLOOKUP, and PivotTable support for easy data matchingFree to download and use for all standard office needs
microsoft office alternative - wps office

Frequently Asked Questions

Will the Power Query output update automatically if I modify the original CSV file?

Yes. If the modified CSV is saved in the exact same location with the same file name, you can simply click 'Refresh All' on the Data tab to automatically update your output worksheet.

Why do I get errors when merging the Output Data query?

Errors typically occur if the column headers in the source file have changed, or if there is a data type mismatch between the 'Number' and 'ParentNumber' columns. Ensure both columns are formatted identically in the Power Query Editor (e.g., both as Text or both as Whole Numbers).

What is the difference between an Inner Join and a Left Outer Join in Power Query?

An Inner Join returns only the rows where there is a match in both specified columns (like Number and ParentNumber). A Left Outer Join keeps all rows from your first table regardless of whether a match exists in the second table.