Sub topic 10
Loading to a Table or Connection Only and Refreshing
This chapter assumes you can build a query in the Power Query Editor, see its Applied Steps, and recognize an Excel table. Here you decide where the results go and how to bring them up to date.
Choosing where results go
When you select Close & Load in the Power Query Editor, Excel puts the result in a default location. Close & Load To... lets you choose.
| Option | What it does | Use it when |
|---|---|---|
| Table | Writes the rows to a worksheet table | People need to see or use the rows directly |
| PivotTable Report | Builds a PivotTable on the result | You want to summarize right away |
| Only Create Connection | Saves the query but writes no rows to a sheet | The query is an intermediate step for other queries |
| Add this data to the Data Model | Stores the rows in the workbook's Data Model | You need relationships or large data sets |
A connection only query still runs. Other queries can reference it, and you can load it to a sheet later.
A worked pattern
Suppose SalesRaw is cleaned by one query, and two other queries build on it. The cleaning query does not need its own worksheet. Load it as connection only. Then load only the final queries as tables.
let
Source = Excel.CurrentWorkbook(){[Name="SalesRaw"]}[Content],
Typed = Table.TransformColumnTypes(Source, {{"Date", type date}, {"Amount", type number}}),
Trimmed = Table.TransformColumns(Typed, {{"Region", each Text.Trim(Text.Clean(_)), type text}})
in
TrimmedName this query SalesClean. In another query, you can start from it by name, as in Source = SalesClean.
Changing the load setting
- On the Data tab, select Queries & Connections.
- Right-click the query and choose Load To....
- Pick a new option and select OK.
Switching to connection only removes the worksheet table. The query stays in the workbook.
Refreshing
Refreshing reruns every Applied Step against the current source and replaces the loaded rows.
- Refresh on the Data tab updates the selected query.
- Refresh All updates every query in the workbook.
- In the Queries & Connections pane, hover over a query and use its refresh icon.
Refreshing a query also refreshes the queries it depends on. In the worked pattern, refreshing a final table reruns SalesClean first.
Common errors
- A column was not found. The source changed a header. Open the failing step and update the column name.
- Data lands on the wrong sheet or overwrites cells. Load to a new worksheet, or choose an existing location with enough free space.
- Nothing seems to change after refresh. Check that the source file was saved. For a CSV or an Excel file on disk, the query reads the saved version, not unsaved edits.
- Refresh is slow. Load helper queries as connection only so they do not also write rows to a sheet.
Exercise
You have a query named SalesClean that two other queries use as their source. You do not need to see its rows on any worksheet. Which load option should you pick for it, and what happens when you refresh one of the other queries?
Show answer
Choose Only Create Connection. When you refresh one of the other queries, Excel also reruns SalesClean first, because that query depends on it. No worksheet table is created for SalesClean.