Power Query course · Lesson 2 of 17
Getting data: files, folders, tables, web pages and databases
Connect Power Query to workbooks, CSV files, folders, Excel tables, web pages and databases, choose Load or Transform, and set privacy levels.
Every query starts with a source. Power Query can read dozens of source types, but in daily work five cover almost everything: other Excel workbooks, text and CSV files, whole folders, tables in the current workbook, and databases or web pages. This lesson walks through each one with exact click paths, shows the first step Power Query writes for it, and ends with the settings that decide whether sources may be combined: privacy levels.
The Navigator and the Load or Transform choice
Whatever source you pick, Power Query first shows a preview. For files with several objects (a workbook with sheets and tables, a database with tables, a web page with HTML tables) the preview is a window called the Navigator: a list of objects on the left, a preview of the selected one on the right. At the bottom you always get the same three buttons:
- Load: load the data as it is to a new worksheet table. Fine only when the data is already clean.
- Load To… (the arrow next to Load): choose Table, PivotTable Report, PivotChart, Only Create Connection, and whether to add the data to the Data Model.
- Transform Data: open the Power Query Editor so you can clean the data first. This is the button you will press most often.
From another Excel workbook
- Choose Data › Get Data › From File › From Excel Workbook (called From Workbook in older versions).
- Browse to the file, for example
HR_headcount_2026.xlsx, and click Import. - In the Navigator, each sheet has a sheet icon and each formatted table or named range has a table icon. Prefer a table when one exists: its size grows and shrinks with the data, while a sheet import includes every used cell, including notes typed below the data.
- Tick Select multiple items if you need several objects; each becomes its own query.
- Click Transform Data.
let
Source = Excel.Workbook(File.Contents("C:\Reports\HR_headcount_2026.xlsx"), null, true),
Staff_Table = Source{[Item="Staff",Kind="Table"]}[Data]
in
Staff_TableThe source workbook does not need to be open. In fact it is better if it is closed, because Power Query reads the last saved version of the file, not what is on someone's screen.
From a text or CSV file
- Choose Data › From Text/CSV (or Data › Get Data › From File › From Text/CSV).
- Select the file, for example
bank_statement_2026-02.csv, and click Import. - Check the three settings at the top of the preview: File Origin (the text encoding; choose 65001: Unicode (UTF-8) if accented names look garbled), Delimiter (Comma, Semicolon, Tab or Custom) and Data Type Detection (based on the first 200 rows by default, or the entire dataset, or do not detect).
- Click Transform Data.
| A | |
|---|---|
| 1 | Date;Description;Debit;Credit;Balance |
| 2 | 02.02.2026;CARD 4411 SUPERMARKET;54,20;;1.845,80 |
| 3 | 03.02.2026;SALARY FEB;;2.350,00;4.195,80 |
| 4 | 05.02.2026;RENT TRANSFER;780,00;;3.415,80 |
Before: a European bank CSV opened naively in Excel. Everything lands in column A because the delimiter is a semicolon, and the decimal comma confuses the numbers.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Date | Description | Debit | Credit | Balance |
| 2 | 2026-02-02 | CARD 4411 SUPERMARKET | 54.2 | null | 1845.8 |
| 3 | 2026-02-03 | SALARY FEB | null | 2350 | 4195.8 |
| 4 | 2026-02-05 | RENT TRANSFER | 780 | null | 3415.8 |
After: the same file through From Text/CSV with Delimiter set to Semicolon and the types set using the German (Germany) locale. Empty cells show as null in the editor.
let
Source = Csv.Document(File.Contents("C:\Bank\bank_statement_2026-02.csv"), [Delimiter=";", Columns=5, Encoding=65001, QuoteStyle=QuoteStyle.Csv]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type with Locale" = Table.TransformColumnTypes(#"Promoted Headers", {{"Date", type date}, {"Debit", type number}, {"Credit", type number}, {"Balance", type number}}, "de-DE")
in
#"Changed Type with Locale"Columns=5 in the code above. Power Query fixes the number of columns when you create the query. If next month's file has a sixth column, it is silently ignored. Delete the Columns=5, part of the step (in the formula bar) if the number of columns may change.From a table or range in the current workbook
- Click inside the data.
- Choose Data › From Table/Range (or From Sheet in newer builds).
- If the data is not yet an Excel table, Excel converts it and asks about headers. Rename the table afterwards in Table Design › Table Name, because the query refers to the name (
Table1is not helpful). - The editor opens immediately; there is no Navigator.
Use this source for lookup lists you maintain by hand (product categories, sales targets, a holiday list), and for parameters stored in cells, which you will meet in Parameters and custom functions.
From a folder
Data › Get Data › From File › From Folder lists every file in a folder and its subfolders, with columns such as Name, Extension, Date modified and Folder Path, plus a Content column holding each file's bytes. From there Combine & Transform Data stacks all files into one table. This is so important that it has its own lesson, Combine files from a folder. For files stored on SharePoint or OneDrive for work, use From SharePoint Folder with the site address instead of a synced local path, so the query works for colleagues too.
From a web page
- Choose Data › From Web.
- Paste the address of a page that contains an HTML table, for example a public statistics page with exchange rates, and click OK.
- If asked how to connect, choose Anonymous for public pages.
- In the Navigator, pick one of the detected tables (
Table 0,Table 1…) or a Suggested Table. The Web View tab shows the page itself so you can see which table is which. - Click Transform Data.
Web queries are fragile: if the site changes its layout, the step that picks Table 0 may suddenly point at a different table. Prefer official CSV downloads or APIs when the site offers them; From Web also accepts the direct address of a CSV or JSON file.
From a database
Company data often lives in SQL Server, Oracle, MySQL, PostgreSQL or Access. Choose Data › Get Data › From Database › From SQL Server Database, type the server name and, optionally, the database. Under Advanced options you can paste a SQL statement, but it is usually better to pick tables in the Navigator and let Power Query translate your filters into SQL itself (a feature called query folding, covered in Performance, query folding and refresh options). Credentials are stored on your computer, not in the workbook, so each colleague who refreshes enters their own.
let
Source = Sql.Database("sql-erp01", "SalesDW"),
dbo_FactSales = Source{[Schema="dbo",Item="FactSales"]}[Data]
in
dbo_FactSalesManaging sources: Data Source Settings
Paths and credentials are kept in Data Source Settings. Open it from the editor with Home › Data Source Settings, or from Excel with Data › Get Data › Data Source Settings. There you can:
- Change Source… to point the query at a different file or server, for example after moving the reports folder.
- Edit Permissions… to change the credentials or the privacy level of a source.
- Clear Permissions to forget stored credentials, which is useful when a password changed.
Privacy levels
When one query combines data from two sources, Power Query may send data from one source to the other. For example, filtering a database table by a list from your workbook could send the list values to the database server inside a SQL statement. Privacy levels stop sensitive data from leaking in that way. Each source gets one of these levels:
| Level | Use for | Effect |
|---|---|---|
| Private | Salaries, personal data, confidential files | Never sent to any other source |
| Organizational | Company servers, SharePoint, shared drives | May be shared with other Organizational sources |
| Public | Public web pages, open data | May be shared with any source |
| None | Not set yet | Excel asks the first time the sources are combined |
If a query combines sources in a way Power Query considers risky, you see the Formula.Firewall error, which says that a query references other queries or steps, so it may not directly access a data source, and asks you to rebuild this data combination. The fixes, in order of preference:
- Set the right privacy level for each source in Data Source Settings › Edit Permissions. Two Organizational sources may be combined freely.
- Restructure the queries: keep each source in its own query and combine them in a separate query that only references other queries.
- As a last resort, on a workbook that never leaves your computer, choose File › Options and settings › Query Options › Current Workbook › Privacy and select Ignore the Privacy Levels and potentially improve performance.
Check yourself
1. Which Navigator button opens the Power Query Editor?
Transform Data opens the editor so you can clean the data before loading.
2. A CSV uses semicolons and decimal commas. What should you set?
The delimiter splits the columns; the locale tells Power Query how to read 1.845,80.
3. Why prefer a table over a sheet when importing from a workbook?
A sheet import includes every used cell, such as notes below the data.
4. What does the Private privacy level do?
Private data is isolated from every other source.
5. Where do you point a query at a moved file?
Change Source updates the path stored in the query.