Have you ever put an analysis together in Power Query, but you’d like to edit the steps once it’s already been loaded? Perhaps you want to tweak a filter or add a new column, for example. Let’s see how to do that in Excel. Follow along with the download file:
Launching the Power Query editor
To get to the query from your workbook, head to Data on the home ribbon, then find Queries & Connections. A new menu will appear to the right of your data listing the current queries in the workbook.
Right now we just have one query, wholesale
. Right-click on it in the menu and select “Edit.” The Power Query editor will now appear:
Editing the Applied Steps
From here we can trace exactly what has been done to the data, make any changes and add more as helpful.
For example, let’s redo the filtering done on the dataset. Head to the Applied Steps menu. Next to “Filtered Rows” you will see a tiny gearwheel-box to the right of “Filtered Rows.” Go ahead and click on that. A Filter Rows menu will appear indicating there are two criteria on this data:
- Filter where
Attribute
does not equalFresh
- Filter where
Attribute
does not equalFrozen
Let’s go ahead and tweak this filter. Perhaps we do not want to filter out Frozen
anymore. Easy enough to do: head to the Advanced section of the menu. Next to this level of the filter you’ll see a ...
option. Click on that and select Delete. This is no longer part of the query:
If you do not see a gearwheel next to the step you want to apply, you can still edit it using the Advanced Editor. This is beyond the scope of this post.
Adding new steps
Along with changing an existing step, it’s also possible to add more steps to the query. Let’s do a personal favorite of mine… add an index column! Make sure your query editor is selecting the last step on the list: Renamed Columns. If you do not do this, you’ll receive a warning message about adding an intermediate column.
After that, go to the home ribbon and select Add Column > Index Column > From 1:
The list continues! Your repeatable data transformation grows.
At this point, we’re ready to head back to Power Query. To do this, select Home on the ribbon, then Close & Load:
Remember that this query had already been loaded to Excel as a table. If you want to change this option, such as loading the results to a PivotTable, check out this post on editing load options in Excel Power Query.
You can compare your workbook results to mine here:
Have you needed to edit an existing query before, and how did you do it? What questions do you have about Power Query? Let me know in the comments.
Leave a Reply