Power Query course · Lesson 1 of 17
What is Power Query? Where it lives and which version you have
What Power Query is, the problems it solves, where to find it in Excel for Windows, Mac and the web, and how versions differ.
Most people who work in Excel spend a surprising part of the week not analysing data but preparing it: deleting the three title rows at the top of an export, fixing dates that arrived as text, trimming spaces from customer names, copying twelve monthly files into one sheet. Power Query is the tool inside Excel that turns that preparation into a recorded, repeatable recipe. You do the cleaning once, Power Query writes down every step, and from then on a single click on Refresh repeats the whole recipe on the latest data.
This course takes you from your first query to writing your own M functions. If you have already read the overview lesson Power Query basics: import, clean, append, merge, refresh in the Excel course, you have seen a quick tour of importing, appending and merging. Here we go slower and deeper: each lesson concentrates on one family of transformations, shows the data before and after, and explains the M code that Power Query writes behind the scenes.
The problem Power Query solves
Imagine you are the sales analyst of a small distributor. Every Monday the ERP system emails you weekly_sales.csv. Every Monday you open it, delete the report header, split the Customer / City column, convert the amounts, remove cancelled orders and paste the result under last week's data. It takes forty minutes, and if you are tired you forget one step. With formulas you could automate part of it, but formulas cannot delete rows, cannot open a file by themselves and get slow when they reference hundreds of thousands of cells.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Weekly sales export | |||
| 2 | Printed: 2026-03-09 | |||
| 3 | Order | Customer / City | Status | Amount |
| 4 | SO-5512 | Nordic Foods / Oslo | Shipped | 1 240,00 |
| 5 | SO-5513 | Agora Market / Athens | Cancelled | 310,50 |
| 6 | SO-5514 | Baltic Trade / Riga | Shipped | 2 015,75 |
Before: the raw export, with report lines on top, two facts in one column, cancelled orders and amounts stored as text with a space as thousands separator.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Order | Customer | City | Amount |
| 2 | SO-5512 | Nordic Foods | Oslo | 1240 |
| 3 | SO-5514 | Baltic Trade | Riga | 2015.75 |
After: the same file after a Power Query recipe of five steps. Next week the recipe runs again with one click.
A query built once handles next week's file, and the week after, without you touching the steps. That is the core promise: you describe the transformation, not the result. The result is recalculated from the source every time you refresh.
What Power Query is, in plain words
- A data connection and transformation engine. It reads data from files, folders, databases, web pages, SharePoint lists and many other sources.
- A step recorder. Every action you take in its editor (remove a column, filter a row, change a type) is saved as a named step in the Applied Steps list.
- A language. The steps are stored as code in a language called M (officially the Power Query Formula Language). You can build everything with buttons, but reading M lets you fix and extend queries. You will learn it in The M language: let, steps, lists, records, tables and each.
- Non-destructive. Power Query never changes the source file. It reads it, transforms a copy in memory, and loads the result to a worksheet table, a PivotTable or the Data Model.
- Shared with Power BI. Power BI Desktop, Microsoft Fabric dataflows and several other Microsoft products use the same engine and the same M language, so your skills transfer directly.
Power Query versus formulas, macros and Power Pivot
| Tool | Best at | Weak at |
|---|---|---|
| Formulas | Live calculations on data already in the sheet | Importing files, deleting rows, reshaping tables |
| Power Query | Getting, cleaning, reshaping and combining data | Cell-by-cell interactive calculations |
| VBA macros | Automating anything in Excel, including formatting and emails | Needs programming; .xlsm files are often blocked |
| Power Pivot / Data Model | Relationships and DAX measures over millions of rows | Cleaning messy source data |
The tools work together. A typical modern workbook uses Power Query to load clean tables, the Data Model to relate them, and a PivotTable or a few formulas such as XLOOKUP or SUMIFS for the final report. Power Query replaces most of the repetitive cleaning macros people used to record, and it works in ordinary .xlsx files, so no macro security warnings appear.
Where Power Query lives in Excel for Windows
In Excel 2016, 2019, 2021, 2024 and Microsoft 365 for Windows, Power Query is built in. It does not carry its own name on the ribbon: Microsoft calls the group Get & Transform Data. You find it on the Data tab, at the left end of the ribbon.
- Data › Get Data: the full menu of sources, organised as From File, From Database, From Azure, From Power Platform, From Online Services and From Other Sources.
- Data › From Text/CSV, From Web and From Table/Range: shortcuts to the three most used sources. In some recent Microsoft 365 builds From Table/Range is labelled From Sheet.
- Data › Recent Sources and Existing Connections: reuse a source you connected to before.
- Data › Queries & Connections: opens a side pane listing every query in the workbook. Double-click a query there to edit it.
- Data › Get Data › Launch Power Query Editor: opens the editor directly, even with no query selected.
Power Query on the Mac
For many years Mac users could only refresh queries made on Windows. Microsoft 365 for Mac now includes the Power Query editor and a growing list of sources. You open it with Data › Get Data (Power Query), which shows a window of data sources instead of the cascading menu you see on Windows. Local files such as Excel workbooks and Text/CSV are supported, as are tables and ranges in the current workbook and some online sources.
- The editor looks almost the same as on Windows, with the Home, Transform and Add Column tabs and the Applied Steps list.
- Fewer connectors are available. Database connectors that rely on Windows drivers, for example ODBC and OLE DB sources, are missing or limited.
- Excel 2016, 2019 and 2021 for Mac (the one-time purchase versions) have a much older and smaller feature set. If something in this course is missing on your Mac, check that you are on a current Microsoft 365 build.
- Queries are stored in the workbook, so a file built on Windows opens on a Mac and can usually be refreshed if the source is reachable from the Mac (paths like
C:\Data\will not exist there).
Power Query in Excel for the web
Excel for the web can refresh queries whose sources it can reach, such as tables in the same workbook and some cloud files. Microsoft has been adding the Power Query editor and Data › Get Data to the browser version step by step. Treat the web version as a good place to refresh and make small edits, and the Windows desktop app as the place to build complex queries. A query that points to a file on your local disk cannot be refreshed in the browser, because the browser cannot see your disk.
Your first look: a two-minute query
Let us make a tiny query so the vocabulary of the next lessons is concrete. Type a small HR list into a sheet, with headers Employee, Department, Start date, Salary.
- Click any cell inside the list.
- Choose Data › From Table/Range (or From Sheet). Excel asks to create a table; keep My table has headers ticked and click OK.
- The Power Query Editor window opens. On the right you see Applied Steps with two steps: Source and Changed Type.
- Click the
Departmentheader, then choose Home › Sort Ascending. A third step, Sorted Rows, appears. - Choose Home › Close & Load. A new sheet opens with a green table holding the sorted result, and the Queries & Connections pane shows the query name and its row count.
- Go back to the original list, add a new employee, then choose Data › Refresh All. The new employee appears in the sorted output.
Behind the buttons, Power Query has written this M code. You can see it with Home › Advanced Editor:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source, {{"Employee", type text}, {"Department", type text}, {"Start date", type date}, {"Salary", Int64.Type}}),
#"Sorted Rows" = Table.Sort(#"Changed Type", {{"Department", Order.Ascending}})
in
#"Sorted Rows"Do not worry about the syntax yet. Notice only that each step has a name, that each step uses the previous step's name as its input, and that the last step is the one returned. That chain is the whole idea of Power Query.
Vocabulary for the rest of the course
| Term | Meaning |
|---|---|
| Query | A named recipe: one source plus a list of steps |
| Applied Steps | The ordered list of transformations in a query |
| Power Query Editor | The window where you build and edit queries |
| M | The language the steps are written in |
| Load | Sending the result to a sheet table, PivotTable or the Data Model |
| Refresh | Re-running every step against the current source data |
| Connection only | A query that is not loaded anywhere, used as a building block for others |
How this course is organised
Lessons 1 to 6 are for beginners: getting data (Getting data: files, folders, tables, web pages and databases), the editor (The Power Query Editor: steps, formula bar and data types), and the everyday cleaning tools. Lessons 7 to 12 reshape and combine data: unpivot, group, append, merge and combine whole folders. Lessons 13 to 16 open the hood: the M language, parameters and functions, calendar tables and performance. The final lesson, Project: a self-updating monthly sales report, puts everything together in a monthly report that refreshes itself.
Check yourself
1. Where is Power Query on the Excel for Windows ribbon?
Since Excel 2016 Power Query lives in the Get & Transform Data group on the Data tab.
2. What happens to the source CSV when you remove rows in a query?
Power Query is non-destructive. It transforms a copy in memory.
3. What is M?
M, the Power Query Formula Language, is the code behind the Applied Steps.
4. A query points to C:\Data\sales.csv. Where can it NOT be refreshed?
The browser cannot read files on your local disk.
5. You typed corrections into a table loaded by a query. What happens at the next refresh?
The output table is rebuilt from the query every time.