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.

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.

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.

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.

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.

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 qualified actuary with over 15 years of experience. He has worked in a variety of industries, including insurance, ad tech, and most recently Power Platform consulting. He is a keen problem solver and has a passion for using technology to make businesses more efficient.

Related Posts

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.

  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.

    • 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.

Get the Latest Microsoft Excel Tips

Follow Us

Follow us to stay up to date with the latest in Microsoft Excel!

Subscribe for awesome Microsoft Excel videos πŸ˜ƒ