BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
Posted by Andy Brown on 29 November 2017
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Reusing a Power BI Desktop Query or Power Query
The Query Editor in Power BI Desktop (also known as Power Query in Excel) is an amazing tool, but does it allow you to re-use queries that you've created? It turns out that the answer is yes - this blog shows how.
You can do lots of amazing things in Power Query - and don't get me started on Power BI itself. To find out more, have a look at our classroom or online Power BI courses.
Firstly, create your query:
You should end up with a series of steps that you want Power BI Desktop to follow to transform your data.
Now go to the Power BI Desktop advanced editor:
Click on this tool on the HOME tab of the Query Editor ribbon.
Copy and paste your query:
Select the test which constitutes the query, and copy it to your clipboard.
This is the underlying language used in Power Query, and is actually called M for short.
In another Power BI Desktop file, choose to create a new query:
Choose this menu option to create a blank query (you have to have some query to work with, otherwise the Advanced Editor button isn't selectable in Query Editor).
Click on the Advanced Editor button again:
Choose to go into the advanced editor a second time.
Delete the existing rather pitiful query:
Select the existing query text, and delete it.
You can now paste in the other query's code to recreate its steps!
The above method shows how to copy a single query. There is an ingenious way to copy all of the queries you have in Query Editor, but it only works if you're using Power Query within Excel (it involves pretending to send feedback to Microsoft, and ticking the Include Formulas checkbox).