Sub topic 14
Where Power Query Editor fits
This chapter assumes you have loaded a dataset with Get data. It also assumes you can switch between Report, Table, and Model views. Power Query Editor is a separate window that sits between your data source and those three views.
What Power Query Editor does
Power Query Editor is the place where you shape data before it reaches the data model. Typical jobs are removing columns, filtering rows, fixing data types, splitting text, and combining files.
Each action you take is saved as a step in a query. Power Query records the steps and replays them every time the data refreshes. You do the cleanup once, and it repeats automatically.
Opening the editor
There are two common ways to reach it:
- On the Home ribbon, select Transform data.
- In the Get data preview dialog, select Transform Data instead of Load.
The editor opens in its own window. These are the parts you will use most:
- Queries pane on the left, with one query per loaded table.
- Data preview in the center, showing a sample of rows.
- Query Settings on the right, with the Applied Steps list.
- Formula bar, which shows the M expression behind the selected step.
Data flow
Nothing you do in the editor changes the source file. The steps only change what gets loaded.
Applying your changes
Select Close & Apply on the Home tab of the editor. Power BI Desktop runs the steps, loads the result, and returns you to the main window. Table view then shows the cleaned data.
If you close the editor with Close only, the main window shows a banner saying there are pending changes. Your queries have not been applied yet, so the model still holds the old data.
Power Query or Table view?
The two views can look alike, but they do different jobs.
| Task | Where to do it |
|---|---|
| Remove or reorder columns, filter rows, merge files | Power Query Editor |
| Check what was loaded | Table view |
| Set a column's display format or default summarization | Table view (Column tools) |
| Add a measure | Report, Table, or Model view |
A rule of thumb: if the change should shape the data on every refresh, make it in Power Query. If it controls how the loaded data is displayed or summarized, make it in the main window.
Common errors
- Forgetting to apply. Edits made in the editor do not appear in Report view until you select Close & Apply.
- A step fails after a refresh. If the source file moves or a column is renamed, a step that refers to it shows an error. Select the failing step in Applied Steps and update the reference.
- Reordering steps. Later steps depend on earlier ones. Moving or deleting a step in the middle can break the steps after it.
- Wrong data type. If a numeric column loads as text, fix the type in the editor so that every refresh gets it right.
Exercise
You removed a column in Power Query Editor and closed the window with Close. Report view still lists the column in the Data pane. Why, and how do you fix it?
Show answer
The change is still pending. Closing without applying leaves the model unchanged. Select Apply changes in the banner, or reopen the editor and use Close & Apply.