Power Query Problems

How to Use Power Query Queries and Steps as Variables

John WilsonJohn Wilson Nov 2, 2026 871 views

Question details

The user wants to know how to reference entire Power Query queries and individual query steps as variables to build dynamic data transformations.

How to Use Power Query Queries and Steps as Variables
Product
Microsoft Excel
Device & OS
not provided
Scenario
Building dynamic tables, combining data sources, fuzzy matching, or setting up percentage calculations in complex data models.
Observed behavior
The goal is to reuse query results and earlier steps as values or variables to simplify complex transformations and maintain reusable data models.
Before you start

Ensure you have your dataset loaded into the Power Query Editor and are comfortable accessing the Advanced Editor, as referencing steps often requires interacting directly with M code.

Solution 1Recommended

Reference Existing Queries as Variables

Reuse the output of an entire query as a starting point or variable in another query to prevent duplicating data extraction steps.

By referencing a query, you create a linked dependency. Any updates made to the original query will automatically flow through to the referenced query, making your data model much easier to maintain.

1
Open the Queries Pane

In the Power Query Editor, expand the left-hand Queries pane to view all your active queries.

2
Reference the Query

Right-click the query you want to use as a variable or base, and select 'Reference' from the context menu.

3
Apply Further Transformations

A new query will be created with the original query's output as its source. You can now add new steps, merge it with other tables, or use it for isolated calculations.

Reference Existing Queries as Variables
Optimization Tip: Referencing queries instead of duplicating them reduces load times and prevents the system from querying the original data source multiple times.
Free Microsoft Office alternative

Simplify Your Data Analysis with WPS Office

While advanced M code scripting is exclusive to Microsoft Excel's Power Query, you can perform powerful data transformations, merging, and filtering effortlessly using WPS Spreadsheet. It offers a familiar interface, highly compatible formatting, and essential data tools for free.

  1. 1. Download and Install: Get WPS Office from the official website and install it on your Windows, Mac, or Linux device.
  2. 2. Open Your Excel File: Launch WPS Spreadsheet and seamlessly open your existing .xlsx workbooks without losing any formatting.
  3. 3. Utilize Data Tools: Navigate to the Data tab to use PivotTables, Data Validation, and Advanced Filtering to analyze your data dynamically.
Free to use, lightweight, and fast to installFully compatible with Microsoft Excel (.xlsx, .xls) formatsBuilt-in advanced formulas, pivot tables, and data consolidation toolsIntuitive interface with no steep learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Why do my Power Query step names have a hashtag and quotes?

In Power Query's M language, step names containing spaces are automatically wrapped in a hashtag and double quotes (e.g., #"Added Custom"). You must include this exact formatting when referencing the step as a variable in the Advanced Editor.

Can I reference a query step from a completely different query?

No, individual steps are scoped only to their specific query. To reuse data from another query, you must reference the entire query as a data source, rather than trying to call its internal steps.

Does referencing a query duplicate the data load?

No, referencing a query creates a logical link rather than duplicating the source data load. This helps optimize performance and keeps your data model efficient by preventing multiple calls to the underlying database or file.