Skip to main content

Insert a saved query as a function

Insert a saved query as an =MS.RUN formula that spills its results into your sheet. See how to insert it, how formulas compare with tables, and what to do if the formula shows an error.

B
Written by Bradley Taylor

Inserting a saved query as a function puts an =MS.RUN formula in the selected cell. The formula spills the query's results into the cells next to it, like any Excel array formula, and updates when you refresh.

Insert from Saved

  1. In your sheet, select the cell where the results should start.

  2. In Saved, open the query's card.

  3. Select Insert as function. The formula lands in the cell and spills its results. The card also shows the formula, so you can copy it into other workbooks.

Insert from the Query Builder

With a saved query open in the Query Builder and no unsaved changes, select the Insert as function (=MS.RUN) button at the bottom of the pane. If you've changed the query and haven't saved, the button inserts an =MS.QUERY formula instead, which holds the whole query in the formula and isn't linked to the saved query.

What the formula looks like

The formula points to the saved query by its ID:

=MS.RUN("your-query-id")

Keep the ID as it is. Renaming the query doesn't change the ID, so the formula keeps working.

Formulas versus tables

Feature

=MS.RUN formula

Table from Run to sheet

Updates

When you refresh, or after a new sync

When you refresh

Size

Up to 5,000 rows

Up to 50,000 rows

Title and sync line

No

Yes

Works inside other formulas

Yes, such as in SUM or FILTER

No

Use a formula when you want results inside a model or next to your own calculations. Use a table for large pulls.

If the formula shows an error

Select the cell to see the reason in the pane.

  • #SPILL!: Cells where the results need to go already have data. Clear them or move the formula.

  • #VALUE!: The result is over 5,000 rows. Add a filter or group the rows, or run the query as a table.

  • #REF!: The saved query was deleted. Select Restore query or Pick another in the pane.

Did this answer your question?