How To Query A Query In Power Query

2017-11-10

Create-First-Import-Query-as-Connection-Only How To Query A Query In Power Query

Today I was using power query to import external data in a CSV file and then do some transformations on the data. I decided I wanted to import my data as a connection only first then perform the transformations in a separate query.

My-Sales-Data-Connection-Only-Query How To Query A Query In Power Query

I had My Sales Data connection only query ready to use in another query. I hadn’t really noticed before, but there’s actually no command in the ribbon to get data from a query. I could have loaded my first query to a table and then queried that table, but I wanted to keep the first query as a connection only so using the From Table/Range command was not possible.

Get-Data-Menu-in-the-Get-and-Transform-Section-of-the-Data-Tab How To Query A Query In Power Query

I diligently searched all the commands in the Get Data menu from the Get & Transform Data section of the Data tab in the ribbon, but could not find a From Query command.

Get-Data-from-Other-Sources-Create-a-Blank-Query How To Query A Query In Power Query

It turns out, the way to query a query is to create a Blank Query and then reference your query as a source.

  1. Press the Get Data button found in the Get & Transform Data section of the Data tab.
  2. Select From Other Sources in the menu.
  3. Select Blank Query in the menu.

Add-Query-Reference-to-the-Query-Editor-Formula-Bar How To Query A Query In Power Query

After creating a blank query, the query editor will open and appear blank. We can now add our My Sales Data connection only query as the source data for our blank query. Do this by typing =#”My Sales Data” into the query editor formula bar and pressing Enter.

Query-of-a-Query-in-the-Query-Editor How To Query A Query In Power Query

A preview of the data from My Sales Data will load into the query editor and you can then begin your transformations as you wish.

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Subscribe

Advertisement

Related Articles

Comments

3 Comments

  1. Ernest Morozov

    How do turn this into a dynamic parameter? Where I can change the “My Sales Data” to some other query. I need the syntex to invoke the custom function here.

    Reply
  2. Maruf Ibragimov

    Wow, that’s awesome.
    It is going to completely change the way I gonna use PQ.
    Thank you so much for such an amazing tip.

    Reply
    • John

      No problem. You can also right click on a query in the query list of the editor and select reference to reference a query.

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get The Latest News

Follow Us

Follow us on social media to stay up to date with the latest tips in Excel!

Pin It on Pinterest

Share This