Sub topic 1
Starting from Get Data: how Power BI connectors work
Every report in Power BI Desktop begins with the same action: Home > Get data. This chapter explains what happens after you click it. You will learn what a connector is, how it turns a file or site into a table, and where the code behind that table lives. The later chapters on Excel, CSV, and SharePoint build on this model.
Prerequisites
This chapter assumes you have:
- Basic familiarity with the Power BI Desktop interface, including the Report, Table, and Model views.
- Experience working with Excel tables and CSV files.
- A working idea of tables, rows, columns, and data types.
You do not need to know Power Query's formula language (called M). You will read a short example here and learn more as you go.
What a connector is
A connector is a component that knows how to reach one kind of data source and return its contents as tables. Power BI Desktop ships with many connectors. Each one handles three jobs:
- Locating the source. It accepts a path, URL, or server name.
- Authenticating. It asks for the credentials that source type supports, such as Windows, Organizational account, or Anonymous.
- Exposing structure. It returns a list of objects (sheets, tables, files, lists) that you can pick from.
The connector does not decide what your final table looks like. It hands back raw material. Power Query then cleans and shapes it, and Power BI loads the result into the data model.
The connectors in this tutorial are:
| Connector (Get data menu) | Typical source | Main M function |
|---|---|---|
| Excel workbook | A local or network `.xlsx` file | `Excel.Workbook` |
| Text/CSV | A delimited text file | `Csv.Document` |
| SharePoint folder | Files on a SharePoint Online site | `SharePoint.Files` |
| SharePoint Online List | A list on a SharePoint Online site | `SharePoint.Tables` |
The Get Data flow
The steps are the same for every connector, even though the dialogs differ.
Choosing a connector
Pick a connector in the Get data dialog. You can search by name or browse the categories (File, Database, Online Services, and others). The same file can often be opened by more than one connector. A .csv file opens with Text/CSV, but also with the Excel connector if you point it at the wrong file type, and the result is an error. Choose the connector that matches the format.
Supplying a location and credentials
Local file connectors ask for a path. SharePoint connectors ask for a site URL. The first time you connect to a source, Power BI asks how to authenticate and stores the answer for that source. You can review and change it later under File > Options and settings > Data source settings. The chapter on credentials and privacy levels covers this in detail.
The Navigator
For sources that contain several objects, the Navigator window lists them with a preview pane. For an Excel workbook you see sheets, tables, and named ranges. Each has its own icon. Ticking the boxes selects which objects become queries. For a CSV file there is a single object, so you see a preview dialog instead, where you can adjust delimiter and encoding.
The Navigator offers two buttons:
- Load sends the selected objects straight to the data model with no changes.
- Transform Data opens Power Query Editor so you can shape the data first.
Prefer Transform Data by default. Loading raw data and fixing it later in the model leads to repeated rework.
Every connection becomes a query
Choosing a source creates a query. A query is a named, saved recipe that produces a table. Each query is a list of steps written in M. Power BI writes this code for you as you click. You can view it in Power Query Editor with Home > Advanced Editor.
Here is what the Excel connector generates when you select a table called Sales, plus a type-setting step:
let
Source = Excel.Workbook(File.Contents("C:\Data\Sales.xlsx"), true, true),
SalesTable = Source{[Item = "Sales", Kind = "Table"]}[Data],
Typed = Table.TransformColumnTypes(SalesTable, {{"OrderDate", type date}, {"Amount", type number}})
in
TypedRead it from top to bottom:
Sourcecalls the connector function.File.Contentsreads the file as binary, andExcel.Workbookinterprets that binary as a workbook. It returns a table listing every sheet, table, and named range in the file. The second argument,true, promotes the first row of each object to headers. The third,true, delays type detection so you can set types yourself.SalesTableis the navigation step. The curly braces filter the list byItemandKind, and[Data]pulls out the nested table.Typedsets the data types for two columns.- The
inline names the step that becomes the query's output.
Each line is one entry in the Applied Steps pane. Click a step to see the data as it looked at that point. The next chapter looks at this pane in more depth.
Where the data goes: Import mode
For Excel, CSV, and SharePoint files, Power BI Desktop copies the data into the model when you load it. This is Import mode. The report then runs against that stored copy, not against the file. Two consequences follow:
- The report shows data as of the last refresh, not the current file contents.
- To pick up changes, you must refresh. In Desktop you click Refresh. After publishing, the Power BI service refreshes on a schedule.
A later chapter explains why these file-based sources have no live-query option and what refresh needs from the service side.
Data source settings and privacy
Each connection records a few settings that are separate from the query code:
- Credentials for that source and level (for example, the whole SharePoint site versus one subfolder).
- A privacy level (Private, Organizational, or Public). Power Query uses it when a single query combines data from more than one source. It blocks data from moving between sources in ways that could leak private information.
Credentials are stored per machine and per source, not inside the .pbix file's query text. When you open a report on another computer, Power BI may ask you to sign in again. This is expected behavior, not corruption.
Common errors at the Get Data stage
| Symptom | Likely cause | What to check |
|---|---|---|
| "We couldn't find the file" or path not found | The path is wrong or the drive is not reachable from this machine | Open the path in File Explorer. Check mapped drives versus UNC paths. |
| "Access to the resource is forbidden" | Saved credentials are for a different account | **Data source settings > Edit Permissions > Clear Permissions**, then sign in again. |
| Navigator is empty or missing a table | The object is not defined as a table or named range, or the file is open in a way that blocks reading | Format the range as a table in Excel (**Ctrl+T**). Save and close the file. |
| Columns all named `Column1`, `Column2` | The first row was not promoted to headers | Use **Use First Row as Headers** or the matching function argument. |
| Dates or numbers appear as text | Types were detected wrongly or not set | Set types explicitly in a step. |
| "The column was not found" after a refresh | Someone renamed or removed a column in the source | Update the step that references the old name. |
Reading the connector choice as a design decision
When more than one connector can reach the same data, the choice affects how the report behaves later:
- A local file connector is simple, but the file lives on one machine.
- A SharePoint connector reads from a site that the Power BI service can reach, which matters for scheduled refresh.
- The navigation step you pick (sheet, table, or named range) controls how stable the query is when the workbook changes. Tables and named ranges tend to survive layout edits better than whole sheets.
The remaining chapters make these decisions concrete, one source type at a time.
Exercise
You choose Get data > Excel workbook, select a table in the Navigator, and click Load. A week later someone renames that table in the workbook, and the refresh fails. In which part of the generated query does the failure occur, and how would you fix it?
Show answer
The failure occurs in the navigation step, Source{[Item = "Sales", Kind = "Table"]}[Data], because the Item value no longer matches any object in the workbook. To fix it, open Power Query Editor, select that step (or edit it in the Advanced Editor), and change the Item value to the new table name. Using Transform Data instead of Load would not have prevented this, but it would have let you review the step before loading.
Exercise
What is the difference between the Navigator's Load and Transform Data buttons, and which one is the better default?
Show answer
Load puts the selected objects straight into the data model without changes. Transform Data opens Power Query Editor first, so you can promote headers, set data types, and clean the data before it loads. Transform Data is the better default because fixing problems before loading avoids rework in the model.