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.

Beginner 16 min read

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.
Tip. Get into the habit of pressing Transform Data. Even when the data looks clean, it is worth checking data types and column names before the first load, because changing them later can break PivotTables built on the output.

From another Excel workbook

  1. Choose Data › Get Data › From File › From Excel Workbook (called From Workbook in older versions).
  2. Browse to the file, for example HR_headcount_2026.xlsx, and click Import.
  3. 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.
  4. Tick Select multiple items if you need several objects; each becomes its own query.
  5. Click Transform Data.
Power Query M
let
    Source = Excel.Workbook(File.Contents("C:\Reports\HR_headcount_2026.xlsx"), null, true),
    Staff_Table = Source{[Item="Staff",Kind="Table"]}[Data]
in
    Staff_Table
The first steps for a workbook source: open the file, then navigate to the object called Staff of kind Table.

The 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

  1. Choose Data › From Text/CSV (or Data › Get Data › From File › From Text/CSV).
  2. Select the file, for example bank_statement_2026-02.csv, and click Import.
  3. 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).
  4. Click Transform Data.
A
1Date;Description;Debit;Credit;Balance
202.02.2026;CARD 4411 SUPERMARKET;54,20;;1.845,80
303.02.2026;SALARY FEB;;2.350,00;4.195,80
405.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.

ABCDE
1DateDescriptionDebitCreditBalance
22026-02-02CARD 4411 SUPERMARKET54.2null1845.8
32026-02-03SALARY FEBnull23504195.8
42026-02-05RENT TRANSFER780null3415.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.

Power Query M
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"
Csv.Document reads the text; the de-DE culture tells Power Query that 1.845,80 means one thousand eight hundred forty-five point eight.
Watch out. Look at 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

  1. Click inside the data.
  2. Choose Data › From Table/Range (or From Sheet in newer builds).
  3. 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 (Table1 is not helpful).
  4. 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

  1. Choose Data › From Web.
  2. Paste the address of a page that contains an HTML table, for example a public statistics page with exchange rates, and click OK.
  3. If asked how to connect, choose Anonymous for public pages.
  4. 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.
  5. 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.

Power Query M
let
    Source = Sql.Database("sql-erp01", "SalesDW"),
    dbo_FactSales = Source{[Schema="dbo",Item="FactSales"]}[Data]
in
    dbo_FactSales
A SQL Server source: server, database, then navigation to one table.
Note. On the Mac, Data › Get Data (Power Query) offers a shorter list. Workbooks, Text/CSV and tables in the current workbook are available, but many database connectors are not. If you need a database on a Mac, ask whether the data can be exported to a file or a SharePoint list, or build the query on Windows.

Managing 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:

LevelUse forEffect
PrivateSalaries, personal data, confidential filesNever sent to any other source
OrganizationalCompany servers, SharePoint, shared drivesMay be shared with other Organizational sources
PublicPublic web pages, open dataMay be shared with any source
NoneNot set yetExcel 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:

  1. Set the right privacy level for each source in Data Source Settings › Edit Permissions. Two Organizational sources may be combined freely.
  2. Restructure the queries: keep each source in its own query and combine them in a separate query that only references other queries.
  3. 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.
Watch out. Ignoring privacy levels is a per-workbook decision, and it is a real risk with confidential data and external sources such as web APIs. Do not turn it on just to make an error message go away without understanding which data travels where.
Tip. Use Data › Get Data › Recent Sources to reconnect to a file or server you used in another workbook. It saves retyping long server names and SharePoint addresses.

Check yourself

1. Which Navigator button opens the Power Query Editor?

2. A CSV uses semicolons and decimal commas. What should you set?

3. Why prefer a table over a sheet when importing from a workbook?

4. What does the Private privacy level do?

5. Where do you point a query at a moved file?