Basics

What Power Query and the M language are

Power Query loads data from files, databases and systems, transforms it in steps it remembers, and repeats those steps on its own next time, automatically or with one click. You'll find it in both Excel and Power BI.

Vojtěch Šíma, Microsoft MVP 5 min read Updated November 24, 2026

In short
  • Power Query loads and transforms data: for example, it combines twelve monthly exports into one table, removes blank rows, splits columns and merges tables on a key.
  • Every step is written in the M language, so next time the whole transformation runs again with the Refresh button, with no copying by hand.
  • You'll find the same Power Query in Excel, in Power BI Desktop and in Fabric as Dataflow Gen2.
  • Behind it is M code, which you can build by clicking, write by hand or have generated.
Contents 6 sections
  1. 01Power Query, what it is
  2. 02Power Query in Excel
  3. 03Power Query in Power BI
  4. 04The M language
  5. 05Where does Power Query in Excel stop being enough?
  6. 06FAQ
What it is
  1. What Power BI is and how it works
  2. What is Microsoft Fabric
  3. What Power Query and the M language are
  4. Copilot in Power BI

All guides

Power Query, what it is

Microsoft's Power Query prepares data for further work. It loads data from a source, transforms it and saves the result to a model in Power BI or to a table in Excel. The source can be a CSV file, an Excel workbook, a whole folder of exports, a SQL Server database, SharePoint, a web page or an API.

In the editor, you usually transform data by clicking: remove a column, filter rows, change a data type, merge two tables. Each click is saved as a step, and the steps line up in the Applied Steps list. When new data arrives next month, Power Query runs the same steps again, on its own and in the same order.

Example

Every month, an accountant downloads a sales export from the ERP as a CSV. The files go into one folder. Power Query loads the whole folder, stacks the files on top of each other, removes the extra headers, fixes the date format and adds a month column. When a thirteenth file arrives, a click on Refresh is all it takes.

Power Query in Excel

In Excel for Windows, Power Query is built in from version 2016 on and in Microsoft 365. You'll find it on the Data tab under the Get Data button. In Excel 2010 and 2013 it was installed as a separate add-in.

You can send a query's result to a sheet as a table, save it only as a connection, or load it into the Excel data model, known as Power Pivot. A sheet has a ceiling of 1,048,576 rows. The data model isn't bound by that ceiling, it handles millions of rows, and you build PivotTables on top of it.

Power Query in Power BI

In Power BI Desktop, Power Query opens with the Transform data button. Put simply, every table in a Power BI model has passed through a Power Query query, even if the author just clicked through it while loading.

Once published to the Power BI Service, the same queries run at every scheduled refresh. When the data sits on a server or drive in your network, the Power BI Service needs an on-premises data gateway to run the queries.

Power Query is built primarily for clicking, and it has several ways to turn clicked steps into code the source handles better and faster. Query folding, for example, can turn some steps into a SQL query that goes straight to the database, which speeds up the whole refresh.

Where you'll find Power Query

WhereWhere the result goesHow it refreshes
ExcelA sheet, or the Excel data modelManually, with the Refresh All button
Power BI DesktopSemantic modelManually; once published, scheduled refresh in the Service
Dataflow Gen2 in FabricLakehouse, warehouse and other destinationsOn a schedule or from a pipeline

The M language

Every click in the Power Query Editor writes one line of M code. You'll see the code in the Advanced Editor: a query starts with the word let, below it is a list of named steps, and at the end, after the word in, is the step whose result gets loaded. One step can look like Table.SelectRows(Source, each [Amount] > 0).

Clicking and code

A click in the editor and a line of M are two forms of the same step. What you click, you can read in the code, and what you write in code, you'll see as a step in the list.

For everyday work, the editor is enough. Writing M by hand pays off when clicking isn't enough:

  • a custom function that applies the same steps to fifty files or tables,
  • parameters, such as a folder path or the date from which data is loaded,
  • loading from a REST API, including paging and sign-in,
  • error handling, so one bad row doesn't bring down the whole refresh.

I recommend learning M to anyone who doesn't want to be limited by the graphical interface and the range of supported connectors, or who wants to consolidate steps and so improve how the whole workflow runs.

Where does Power Query in Excel stop being enough?

Power Query in Excel doesn't refresh on its own. Someone has to open the workbook and click Refresh. Scheduled refresh only comes with the Power BI Service or Dataflow Gen2 in Fabric, or with automation through Power Automate. A custom scheduled script can also trigger the refresh, but this guide assumes a route without programming.

On top of that, a workbook with queries is still a file. A colleague with last week's copy has different numbers, and the calculations built on the result live in the formulas of each workbook separately. Once the same report is put together for more people, Power BI takes it over with the same Power Query queries, just published to one place. Where exactly the line lies is covered in the guide Power BI or Excel.

FAQ

Is Power Query part of Excel?

In Excel for Windows from version 2016 on and in Excel from Microsoft 365, yes, you'll find it on the Data tab. In Excel 2010 and 2013 it was installed as an add-in. Excel for Mac has Power Query too, with a smaller choice of data sources.

What's the difference between Power Query and Power Pivot?

Power Query loads and transforms the data. Power Pivot is the Excel data model that holds the transformed tables, the relationships between them and the DAX calculations. They usually work together: Power Query fills the model, and PivotTables sit on top of the model. Power BI uses the same pair.

Is Power Query in Excel the same as in Power BI?

The M language and the editor are almost the same, so you can copy a query from one to the other. What differs is the choice of connectors and where the result goes: in Excel to a sheet or the data model, in Power BI to a semantic model that refreshes on a schedule in the Service.

Do I need to know how to program to use Power Query?

Most of the work you click through in the editor, and the M code writes itself. Knowing M helps with custom functions, loading from APIs and finding slow steps. You can start without it.

What is query folding?

Query folding means Power Query translates your steps into the database's language and lets the database do the filtering and totals. Only the result then comes back to Power Query, and the refresh is faster. When a step can't be translated, Power Query does the rest of the work itself and the refresh slows down.

Daatlers table: Where you'll find Power Query.

Where do you stand?

Power Query M Language

€3,500per group

For those for whom clicking in Power Query isn't enough: M syntax, custom functions, connectors, loading from REST APIs and error handling.

What exactly you get

Contact

Still have a question?

Send it to us. We'll answer even if nothing more comes of it. You'll hear from us within two working days.

Book an intro call

Please fill in your name and company.

Please check your email address, that's where we send our reply.

Without your consent we can't reply.

Sent. We'll get back to you within two working days. In a hurry? Call David on +420 777 542 792.