Power Query Undo lets you revert recent transformations in your data query, restoring previous states without restarting from scratch. It works by stepping backward through the Applied Steps list in the Query Editor, and requires no setup beyond having an active query open in Excel or Power BI. This feature is essential for correcting accidental changes, testing alternatives, or recovering from overwrites.
What You'll Need
- Microsoft Excel 2016 or later, or Power BI Desktop
- An open query in Power Query Editor (accessed via Data > Get Data > Transform Data or the Power Query tab)
- At least one applied step in your query’s Applied Steps panel
Step-by-Step
- Open the Excel workbook or Power BI Desktop file containing your query.
- Go to the Data tab in Excel or the Home tab in Power BI, then select Transform Data or Transform Data > Edit Queries to open the Power Query Editor.
- In the Power Query Editor window, locate the Applied Steps pane on the right-hand side. This panel lists every transformation applied to your data, from the original source to the most recent step.
- Identify the step you wish to undo. Steps are listed in chronological order, with the most recent at the top.
- Right-click the step you want to remove. A context menu will appear.
- Select Delete from the context menu. This removes the step and all steps that came after it, effectively undoing the change.
- Alternatively, click directly on any earlier step in the Applied Steps list to make it the active state. This instantly reverts the query to the condition after that step, hiding all subsequent steps.
- After undoing the desired step(s), click Close & Apply in the top-left corner of the Power Query Editor to save your changes and return to the main Excel or Power BI interface.
Common Mistakes
- Clicking the Undo button (Ctrl+Z) in the main Excel or Power BI window instead of in the Power Query Editor — this only reverses actions in the worksheet or report canvas, not the query transformations.
- Deleting the wrong step without checking its dependencies — removing an early step may break later ones that rely on its output, causing errors when you click Close & Apply.
- Assuming Undo works after closing the Power Query Editor — once you click Close & Apply, you cannot undo steps using the Applied Steps list until you reopen the editor.
- Trying to undo a step that has been saved and closed multiple times — Power Query only remembers steps since the last time you clicked Close & Apply. There is no history beyond the current session.
- Confusing the Power Query Undo with Excel’s worksheet Undo — they are entirely separate systems. Query edits are stored in the M code behind the scenes and are not affected by Ctrl+Z in the main grid.
Tips
- Before applying major transformations like merging tables or pivoting columns, duplicate your query (right-click the query name in the Queries pane > Duplicate). This gives you a safety copy you can revert to if things go wrong.
- Use descriptive names for your steps (double-click a step name to rename it) so it’s easier to identify what each one does when you need to undo.
- After undoing a step, review the data preview pane to confirm the result matches your expectation before clicking Close & Apply.
- If you’ve undone too far and want to restore a deleted step, you can often reapply it manually by repeating the original transformation — for example, re-filtering, re-sorting, or re-merging.
- Use the View > Query Settings pane to see the M code generated by each step. This helps you understand what’s happening under the hood, especially when troubleshooting errors after undoing.
- Keep your Applied Steps list clean by removing unnecessary steps like duplicate column creations or unused filters — it makes undoing more efficient and reduces clutter.
Troubleshooting
- If you can’t see the Applied Steps pane, ensure you’re in Power Query Editor and not the main Excel or Power BI window. Go to View > Query Settings if the pane is hidden.
- If right-clicking a step doesn’t show Delete, make sure you’re not on the source step (e.g., ‘Source’ or ‘Imported Table’). You cannot delete the source step — only transformations applied after it.
- If clicking Close & Apply results in an error after undoing a step, check the error message. It may indicate a broken reference, such as a column name no longer existing. Reapply the step or adjust dependent steps manually.
- If you accidentally closed the Power Query Editor without saving and want to undo changes, reopen the editor — your last saved state will be restored. Power Query does not auto-save unsaved edits.
- If the query fails to load after undoing steps, verify your data source is still accessible (e.g., file paths haven’t changed, login credentials are valid). Undoing steps won’t fix broken connections.
- If you’ve deleted multiple steps and now need a specific one back, use the “Advanced Editor” (View > Advanced Editor) to manually restore the M code from a backup or from a previously saved version of the query.