Power Query has an undo option that works differently than Excel.
While in Excel, you can use Ctrl+Z to undo, Power Query works differently.
In Power Query, all your steps are recorded in a sequential order, and to undo any step, you need to go back to the step that you want.
Let me show you how it works.
This Tutorial Covers:
ToggleUndo in Power Query
When working with Power Query, you will see that all your steps are recorded sequentially in the Applied Steps pane, as shown below.
As of now, the result that I see in the Power Query editor is the result returned by the last step (named Removed Columns).
Undo One Step
Now, to undo one step (which means removing the changes done by the Removed Columns step and reverting back to get the result returned by the Filtered Rows step), simply put your cursor on the ‘X’ icon in the Removed Columns step and click on it.
When you do this, Power Query is going to remove the Removed Columns step, and you will get the result till the Filtered Rows step.
This is how you can undo one step in Power Query.
Caution: Once you delete a step in Power Query, there is no way to get it back. The only way to get it back is to recreate it from scratch.
Undo All Steps After a Specific Step
If you want to undo multiple steps (for example get the result only from the Source data and remove all the steps after it), follow the steps below:
- Place your cursor on the step till which you want to undo. In this example, since I want to get the result from the Source step, I would place my cursor on the step after the Source step.
- Right-click and then select the option Delete Until End.
This will remove all the steps after the Source step.
So, instead of removing one step at a time, if you want to remove all the steps in one go, you can use the above method.
Note: If you want to remove multiple steps, and if these steps are not consecutive, then you will have to individually go to each step and click on the X icon for that step.
Undo Without Deleting Steps
Power Query allows you to see the result of each step in the Power Query editor.
So, if I want to see the result of the Filtered Rows step, I don’t need to delete the steps after it.
All I need to do is select the Filtered Rows step in the Applied Steps pane, and it will show me the result of this step in the Power Query data preview area.
This means that you can undo steps without actually deleting the steps.
Pro Tip: Before deleting any step, always have a look at all the steps to ensure that you do not end up deleting anything that you may need later. Remember, once you delete a step, you cannot get it back.
Important Considerations When Deleting Steps in Power Query
Here are some important considerations to know when you are undoing a step in Power Query.
No Redo After Undo
Unlike Excel, you cannot redo after the undo step.
So, if you delete a step in Power Query, it’s gone for good, and there is no way to recover it. Be very sure when you are deleting a step in Power Query.
If you are not completely sure, it is a good idea to make a backup copy of your file.
Deleting Step Can Break Your Query
Power Query works by using the result of the previous step in the next step.
So it’s possible that when you delete a step, it may break your query (because there are dependencies that the subsequent steps have on the one you deleted).
If that’s the case, Power Query will warn you about it while you are deleting the step. It’ll show you a message box as shown below.
In this article, I showed you how to undo steps in Power Query.
While there is no traditional undo option in Power Query, it can be done by deleting the steps that you do not need.
I hope you found this article helpful. If you have any questions or suggestions for me, please let me know in the comments section.
Other Excel & Power Query articles you may also like: