Sub topic 2
Connection-only queries and where results are loaded
This chapter covers what happens to a query's output after the last step runs. Merge and append work best when the inputs are staging queries that never appear on a worksheet. The next chapters assume you can set that up.
It assumes you can open the Power Query Editor from Data > Get Data, and that you know the Applied Steps list and the Queries pane. It also assumes you know what a table's columns and data types are.
Every query has a load destination
A query has two separate parts:
- The steps. These define how the data is shaped. They are stored in the workbook as M code.
- The load setting. This says where Excel puts the result after the steps run.
Changing one does not change the other. You can move a query's output from a worksheet to the Data Model, or switch it off entirely, and the steps stay as they were.
The load options
The Import Data dialog (and the Load To... command) offers these choices:
| Option | What Excel does | Typical use |
|---|---|---|
| Table | Writes the result into an Excel table on a new or existing worksheet | Results you want to read, filter, or reference with formulas |
| PivotTable Report | Loads the result and builds a PivotTable on a worksheet | Quick summaries |
| PivotChart | Loads the result and builds a PivotChart | Quick charts |
| Only Create Connection | Saves the query but writes no data anywhere | Staging inputs for merge and append |
| Add this data to the Data Model | A checkbox. Stores the result in the workbook's Data Model | Large tables, relationships between tables, or Power Pivot measures |
The checkbox can be combined with other choices. For example, you can load to a table and also add to the Data Model, or choose Only Create Connection and tick the checkbox. The second combination keeps the data off the sheet and stores it in the Data Model.
A query set to Only Create Connection is a connection-only query. It still exists, it still has steps, and other queries can use it. It just has no output of its own.
Where to set the destination
There are three common routes.
- Close & Load in the Power Query Editor (Home tab) loads the query to a table on a new worksheet. This is the default, and it is easy to accept without noticing.
- Close & Load To... in the same menu opens the dialog from the table above, so you choose the destination yourself.
- In Excel, open the Queries & Connections pane, right-click a query, and choose Load To.... Use this to change a query that is already loaded.
The Queries & Connections pane shows the current state under each query name. You will see text such as "Connection only" or "12,480 rows loaded". Check it after every change, because it is the quickest way to see which queries write data.
Why merge and append want connection-only inputs
Suppose you have Sales_2023, Sales_2024, and Customers. Your goal is one combined sales table with customer names. The two sales tables are only ingredients, and so is Customers. If all three load to worksheets, you have three tables to maintain and a high chance someone reads the wrong one.
A cleaner setup:
Sales_2023,Sales_2024, andCustomersare connection-only.- A new query,
Sales_All, combines them and loads to a table.
Connection-only inputs have these advantages:
- The workbook is smaller, because intermediate data is not stored twice.
- Only the final result is visible, so readers see one table.
- Each input query holds the cleaning steps for one source. You fix a problem once.
The merge and append dialogs list every query in the workbook, whether loaded or not. A connection-only query is a normal choice there.
Reference or duplicate
To build a new query from an existing one, right-click it in the Queries pane. Two commands look similar.
- Duplicate copies all the steps into a new, independent query. If the source changes, you must update both copies.
- Reference creates a new query whose first step reads the output of the original. The new query follows the original: fix a data type in the original and the referencing query picks it up on the next refresh.
For staging, Reference is usually what you want. The M code for a referenced query is short:
let
Source = Sales_2023
in
SourceHere Sales_2023 is the name of another query in the workbook. Query names are used as identifiers in M, so renaming a query later makes Power Query update the references, as long as you rename in the Queries pane. A name with spaces appears in code as #"Sales 2023". Short names without spaces keep the M readable.
Append as New and Merge as New
On the Home tab, Append Queries and Merge Queries each have an "as New" variant. The distinction matters for load settings.
- Append Queries and Merge Queries add a step to the current query and change its output. The other query you picked is untouched.
- Append Queries as New and Merge Queries as New create a new query and leave both inputs unchanged.
With the "as New" form, the original queries keep whatever load setting they had. If they were loading to worksheets, they still are, so you must switch them to connection-only yourself. The new query loads with the default, which is a table on a new worksheet.
The in-place form changes the current query's output but not the other one's load setting. A frequent surprise is two tables on two worksheets, where one should have been absorbed.
Common errors
The same rows appear twice. Sales_2024 was appended into Sales_2023 in place, and both are still loaded to sheets. Totals computed over both sheets double count. Set the inputs to connection-only and keep one loaded result.
A dependent query breaks. You delete or rename a query that others depend on. Power Query warns you when you delete one with dependents. If you ignore the warning, the dependents fail with an error stating that the query was not found. Check View > Query Dependencies in the editor first. It draws the same shape as the diagram above, with your own query names.
Nothing seems to refresh. A connection-only query writes no output, so refreshing it alone shows no visible change. It runs when a loaded query that depends on it is refreshed. To see its results, open it in the editor or change its load destination.
Rows are cut off. A worksheet table holds at most 1,048,576 rows. If a result might exceed that, load it to the Data Model instead and analyze it with a PivotTable.
Changing the destination and expecting changed data. Moving a query from a table to connection-only deletes the worksheet table that Excel created for it. Formulas that referenced that table then show #REF! errors. Do the switch before anything else depends on the table.
Switching a loaded query to connection-only
- In Excel, open Data > Queries & Connections.
- Right-click the query and choose Load To....
- Select Only Create Connection.
- Confirm the warning that the existing data will be removed from the worksheet.
The query's steps are unchanged, and the pane now shows "Connection only" beneath its name.
A note on refresh cost
Connection-only does not mean cached. When a loaded query depends on several staging queries, Power Query may evaluate a shared source more than once during a refresh. For small tables this is invisible. For slow sources, such as large files or web calls, the cost can be noticeable. The final chapter returns to this. For now, keep staging queries simple and put heavy shaping in them only once.
Exercise
You have Sales2023 and Sales2024, both loaded to worksheets. You use Append Queries as New to create SalesAll. Which queries now write data to worksheets, and what should you change so only SalesAll does?
Show answer
All three do. Sales2023 and Sales2024 keep their original load settings, and SalesAll loads to a table by default. Open Load To... for Sales2023 and Sales2024 and choose Only Create Connection, which leaves SalesAll as the only visible result.
Exercise
A colleague says that refreshing a connection-only query in the Queries & Connections pane shows no new rows on any sheet. Is something wrong?
Show answer
No. A connection-only query has no output. It is evaluated when a loaded query that depends on it is refreshed, so the new rows appear in that loaded query's table.
Exercise
Why is Reference usually a better choice than Duplicate when building staging queries for a merge?
Show answer
Reference makes the new query start from the original's output, so a fix made in the original (such as a corrected data type) flows through on refresh. Duplicate creates an independent copy, so the same fix must be made in each copy.