Yes, you can undo most actions in Power Query, but with a major catch: the undo history is cleared the moment you apply your changes and load data back into Excel. While you’re inside the Power Query Editor, Ctrl+Z (or the Undo button) reverses your last step. However, once you click Close & Load and return to the worksheet, that undo history is gone—your only options are to delete the query and start over, or edit the query steps manually. This article explains exactly how undo works in Power Query, what you can and can’t reverse, and how to protect yourself from losing work.
How Undo Works Inside the Power Query Editor
When you open the Power Query Editor (by double-clicking a query in the Queries & Connections pane, or via Data > Get Data > Launch Power Query Editor), you’re working in a separate window. This editor has its own undo stack, separate from Excel’s main undo. You can press Ctrl+Z (Windows) or Cmd+Z (Mac) to undo your most recent change, whether that’s a transformation, a rename, or a deleted step. The Undo button in the toolbar does the same thing.
However, there are two important limitations:
- Undo only works for actions taken in the current editing session. If you close the Power Query Editor and reopen it later, the undo history is reset. You can’t undo changes from a previous session.
- You cannot undo a step that has already been applied and loaded. Once you click Close & Load, the undo stack is cleared. Even if you immediately press Ctrl+Z in Excel, it won’t revert the query changes—it will only undo the act of loading (which removes the table from the sheet, but the query definition remains changed).
What Happens When You Click Close & Load?
Clicking Close & Load (or Close & Load To…) executes the query and writes the results to a worksheet or the data model. This action is the point of no return for undo. After this, the Power Query Editor’s undo history is discarded. If you realize you made a mistake, you have two options:
- Edit the query steps: Go to the Queries & Connections pane, double-click the query to reopen the editor, and manually modify or delete the offending step in the Applied Steps pane on the right.
- Delete and recreate the query: If the mistake is fundamental, you can delete the query entirely (right-click the query in the Queries & Connections pane and choose Delete) and start from scratch.
There is no “revert to last saved version” feature for queries. The only safety net is to save a copy of your workbook before making significant changes.
Why Power Query Undo Is Different from Excel’s Undo
Excel’s main worksheet undo works because Excel stores a history of changes to cell values, formatting, and sheet structure. Power Query, however, is a data transformation engine—it doesn’t modify the original data source; it creates a series of transformation steps that are applied in sequence. Each step is a separate query (in M code) that references the previous one. The undo function in the editor simply removes the last step from that sequence. But once the query is loaded, the sequence is baked into the workbook’s data model, and the undo history is no longer stored anywhere.
This design means that Power Query is not a place for exploratory trial-and-error without consequences. You need to be deliberate about your steps, or use the editor’s built-in safety features (like the Delete button for steps) to remove unwanted transformations.
Common Mistakes and How to Recover
Here are typical scenarios where users wish they could undo, and what actually works:
- You deleted a step by mistake. If you haven’t closed the editor yet, Ctrl+Z will bring it back. If you’ve already closed and loaded, you can’t undo the deletion. You can only re-add the step manually, which requires knowing exactly what it did.
- You changed a column type and it broke your data. You can reopen the editor and change the type back, or delete the “Changed Type” step. This is often easier than undoing because the step is visible in the Applied Steps list.
- You merged queries incorrectly and got errors. You can edit the merge step or remove it entirely. The editor shows a warning icon next to steps with errors.
- You loaded data to the wrong worksheet. You can delete the loaded table and re-run the query with a different destination, using Close & Load To….
How to Protect Yourself Without Undo
Since you can’t rely on undo after loading, here are practical ways to avoid losing work:
- Save a copy of your workbook before starting a query. This is the simplest safety net. If something goes wrong, you can revert to the saved version.
- Use the “Enter Step” button (the small fx icon) to add custom steps. This lets you write M code directly, and you can see exactly what each step does, making it easier to edit later.
- Name your steps clearly. In the Applied Steps pane, right-click a step and choose Rename. This helps you identify and remove the right step later.
- Test on a small sample first. Use the Data > Get Data > Launch Power Query Editor and apply transformations to a subset of data (e.g., filter rows to a few hundred) before loading the full dataset.
- Keep a text file of your M code. In the editor, go to View > Advanced Editor, copy the code, and paste it into a text file. If you ever need to recreate the query, you can paste it back.
Power Query vs. Excel Formulas: Undo Differences
If you’re used to Excel formulas, you might expect undo to work the same way. But there’s a fundamental difference: Excel formulas are recalculated in real-time, and undo affects the formula itself. Power Query steps are stored as a list, and undo only affects that list while you’re editing. Once the query is loaded, the steps are compiled into a data refresh operation—undo can’t touch that.
Another difference: if you change a data source (e.g., a CSV file), Power Query will refresh and reapply all steps. If a step fails, you’ll get an error, and you can’t undo the refresh—you must fix the step or the source.
Frequently Asked Questions
Can I undo a Power Query refresh?
No. When you refresh a query (right-click the query in Queries & Connections and choose Refresh), the data is re-imported and all steps are reapplied. The undo history is cleared, and the previous data is overwritten. If the refresh introduces errors, you can’t undo it—you must edit the steps or the source.
Is there a way to undo a deleted query?
If you delete a query from the Queries & Connections pane, it’s gone immediately. Excel’s undo (Ctrl+Z) does not restore it. The only recovery is to have a backup copy of the workbook, or to recreate the query from scratch (if you saved the M code).
Does Ctrl+Z work in Power Query on Mac?
Yes, on Mac you use Cmd+Z (⌘Z) inside the Power Query Editor. The same limitations apply—undo only works within the current editing session, and it’s cleared after you close and load.
What is the “Applied Steps” pane and how does it help with undo?
The Applied Steps pane (on the right side of the Power Query Editor) lists every transformation you’ve applied, in order. You can click any step to see the data at that point. You can also right-click a step and choose Delete to remove it, which is like a manual undo. This is often more reliable than Ctrl+Z because you can see exactly what you’re removing.
Can I undo a step that has a warning icon?
Yes, you can delete the step that’s causing the warning, or edit it. The warning doesn’t prevent you from using undo or deleting the step. However, if the step has already been loaded and you’re seeing the warning in the editor, you can still fix it before loading again.
Does Power Query have a version history?
No, Power Query does not have a built-in version history. The only way to track changes is to save different versions of your workbook manually, or use Excel’s AutoSave feature (if you’re using OneDrive or SharePoint) which keeps previous versions of the entire workbook—but that includes the query definitions, so you could restore an older version of the file.
Related
- Excel Group Lake Jackson TX: What It Is & Services
- Excel Flexi Timesheet Template UK: How to Build One
- Excel First Letter Uppercase Rest Lowercase?
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel Freeze Panes Greyed Out? Causes and Fixes ExplainedIf Excel’s Freeze Panes command is greyed out, first switch to Normal view, finish editing any cell, and…
- How to Retrieve Archived Emails in Outlook on Any DeviceTo retrieve an archived email in Outlook, open the Archive folder, find the message, then move it back…
- Bill Format in Excel: How to Create and Use a BillTo make a bill format in Excel, create a worksheet with your business and customer details, a numbered…
- Excel Protect Sheet Except for Selected Users: How It WorksYes. In Excel for Microsoft 365 on Windows, use Review > Allow Edit Ranges to designate cells and,…
- Parse Text to Columns in Excel: Steps and TipsTo parse text into separate Excel columns, select the cells, then choose Data > Text to Columns and…
- Excel Not Responding: Should You Wait or Force Quit?If Excel says Not Responding, wait briefly if the workbook may be calculating, refreshing data, or saving; do…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.