Sub topic 16
Close & Apply and refreshing the cleaned data
This chapter assumes you can open the Power Query Editor, read the Applied Steps pane, and have a cleaned query with correct types, handled nulls, and removed duplicates. Here you load that result into the Power BI model and keep it current.
What Close & Apply does
Changes in the Power Query Editor are not in your report yet. They exist only as saved steps. Close & Apply on the Home tab does two things:
- It closes the editor and keeps your queries.
- It runs every query against its source and loads the resulting tables into the model.
If you choose Close instead, the editor closes but nothing is loaded. Power BI Desktop then shows a banner saying there are pending changes. Pick Apply changes on that banner to finish the load.
Choosing what loads
Not every query should become a table in the model. Staging queries and parameters exist only to feed other queries. To stop one from loading:
- Right-click the query in the Queries pane.
- Clear Enable load.
The query name turns italic. It still runs when another query depends on it, but it adds no table to the model. This keeps the model small and the field list clean.
Refreshing the cleaned data
The model holds a copy of the data from the last load. When the source changes, you refresh to repeat the whole process.
- On the Home tab of the main window, select Refresh. Power BI re-runs every loading query and applies all the steps again.
- Your cleaning rules apply to the new data automatically. A new row with extra spaces is trimmed in the same way as an old one.
- In the Power BI service, a scheduled refresh does the same work on a timer. A gateway is needed if the source is on-premises.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Refresh fails with "column not found" | A source column was renamed or removed, and a step refers to it by name | Open the failing step and correct the column name, or ask the source owner to restore it |
| Values turn into errors after refresh | New data does not match a type you set, such as text in a number column | Handle the error with Replace Errors, or fix the source |
| Refresh is slow | Many rows or steps that prevent query folding | Filter early and review the folding guidance from the earlier chapter |
| Table missing from the field list | Enable load is cleared | Turn Enable load back on |
| Credentials or privacy prompt | The source or a combined source needs permission settings | Update them under Data source settings |
Steps that refer to columns by name break when the source changes. A step that changes a type for Amount fails if the column becomes Total. Check the step named in the error message and compare it with the current source.
A quick check after loading
After Close & Apply, confirm the load worked:
- Open the Data pane on the right and expand each table.
- Check that numeric fields show the sigma icon and dates show the calendar icon.
- Open Table view and look for blanks, "Unknown" labels, or zeros where you expected real values.
If a column looks wrong here, return to the editor with Transform data, fix the step, and apply again.
Exercise
You cleared "Enable load" on a staging query, and a second query that references it still loads correctly. Why does that work, and what does it save?
Show answer
A query that is not loaded still runs whenever another query depends on it, so the second query gets its data. Not loading the staging query keeps an extra table out of the model, which keeps the model smaller and the field list simpler.
Exercise
After a refresh, your Amount column shows errors for some rows. The source now contains the text "n/a" in a few rows. Name two ways to deal with this in the query.
Show answer
Add a Replace Errors step on Amount to turn errors into a value such as 0 or null, or remove the error rows with Remove Errors. A third option is to replace "n/a" with null before the type change.