You can reuse applied steps from one Power Query query in another query by copying the query, referencing it, or exporting its steps as a custom function. The most straightforward method is to duplicate the query that contains the steps you want, then modify the duplicate. For more advanced reuse, you can create a reference to the original query so that changes to the source steps flow through, or you can convert the steps into a custom function that accepts parameters. This guide walks through each approach step by step, using only the standard Power Query Editor features available in Excel for Windows and Mac. Menu labels can differ slightly by Excel version and region, but the core functionality is the same.
What You'll Need
- Excel 2016 or later with Power Query built in (Excel 2010 and 2013 require the free Power Query add-in from Microsoft).
- At least one existing query that already contains the applied steps you want to reuse.
- Basic familiarity with the Power Query Editor: opening it, selecting queries, and viewing the Applied Steps pane.
Step-by-Step
- Open the Power Query Editor. In Excel, go to the Data tab and click Get Data > Launch Power Query Editor (or click Queries & Connections and double-click a query). The editor opens in a separate window.
- Locate the query with the steps you want to reuse. In the Queries pane on the left, find the query that already has the applied steps you need. Click it to select it.
- Duplicate the query (simplest reuse). Right-click the query name in the Queries pane and choose Duplicate. A copy appears with the same steps. Rename it by right-clicking and choosing Rename, then adjust the source or any step that needs to change. This is the fastest way to reuse steps when you do not need the original to stay linked.
- Alternatively, create a reference (linked reuse). Right-click the original query and choose Reference. A new query is created that points to the original query as its source. Any changes you make to the original query's steps will automatically appear in the referenced query. This is useful when you want a base query that multiple other queries build on.
- Review the Applied Steps pane. With the new query selected, look at the Applied Steps pane on the right. You will see the same steps as the original (for a duplicate) or a single Source step pointing to the original query (for a reference). Click any step to preview its output.
- Modify steps as needed. For a duplicate, you can edit, reorder, or delete steps freely. For a reference, you can add new steps after the Source step; the original steps remain intact in the original query. To edit a step, click it and use the formula bar or the step's gear icon.
- Convert steps into a custom function (advanced reuse). If you want to reuse the same logic with different parameters, right-click the query, choose Create Function. In the dialog, give the function a name and define parameters by replacing specific values in the steps with parameter names. Power Query then generates a function query that you can invoke from other queries.
- Invoke the custom function. In another query, go to Add Column > Invoke Custom Function, select your function, and provide the required parameters. This applies the reused steps to each row or table you specify.
- Close and load. When finished, click Close & Load (or Close & Load To) on the Home tab to load the new query to a worksheet or the Data Model. The reused steps are now part of a standalone query.
Common Mistakes
- Editing the original query after duplicating. A duplicate is independent; changes to the original do not affect it. If you need linked updates, use Reference instead.
- Forgetting to rename duplicated queries. Excel appends a number (e.g., Query1 (2)), which can cause confusion later. Rename immediately.
- Assuming a reference shares all steps. A reference only points to the original query as its source; steps added to the reference do not appear in the original.
- Creating a function without testing parameters. If parameter names are misspelled or types are wrong, the function will fail when invoked. Test with a small table first.
- Overlooking query dependencies. If you delete or rename a query that others reference, those references break. Check the Queries pane for dependency arrows before making changes.
Tips
- Use descriptive names for queries and functions so you can identify reused logic at a glance.
- Group related queries into folders in the Queries pane (right-click > Move To Group) to keep reuse organized.
- Document parameters in the function's description field when creating a custom function.
- Before duplicating, consider whether a reference would be more maintainable; references reduce duplication of logic.
- Use the Advanced Editor to view and copy M code if you need to reuse steps across workbooks.
Troubleshooting
- The duplicated query shows errors. Check that the source data is still available and that step references (like column names) match. Click the error step to see details.
- The referenced query does not update. Ensure the original query has been refreshed. References pull from the original query's last loaded result; refresh both queries.
- Custom function fails when invoked. Verify parameter names and data types. Open the function query and test it by invoking it manually with sample values.
- Cannot find Create Function. This option appears only when the query is not already a function and when it contains steps that can be parameterized. Try right-clicking the query name; if unavailable, use the Advanced Editor to manually create a function.
- Steps are greyed out or uneditable. Some steps, like those from a referenced query, cannot be edited directly. Add new steps after the reference or edit the original query.
Frequently Asked Questions
Can I reuse applied steps across different workbooks?
Yes. You can copy the query from one workbook to another by right-clicking the query in the Queries pane, choosing Copy, then pasting into the Queries pane of another workbook's Power Query Editor. Alternatively, export the query's M code via the Advanced Editor and paste it into a new blank query.
What is the difference between Duplicate and Reference?
Duplicate creates an independent copy of the query with all its steps. Reference creates a new query that uses the original query as its source; changes to the original query's steps propagate to the reference, but steps added to the reference do not affect the original.
Can I reuse only some steps from a query?
Not directly. You can duplicate the query and then delete the steps you do not need, or create a reference and then add steps that filter or transform the output. For partial reuse, duplicating and trimming is usually simplest.
How do I update a custom function if the source query changes?
Custom functions are separate queries. If the original query changes, you must manually update the function's steps or recreate the function. References inside the function to other queries will update automatically if those queries are refreshed.
Why does my referenced query show a different row count?
The referenced query may have additional steps applied after the reference, or the original query may not have been refreshed. Check the Applied Steps in both queries and refresh the original first.
Can I reuse steps from a query that loads to the Data Model?
Yes, you can duplicate or reference a query regardless of its load destination. However, be mindful of data model size if you create many duplicates.