Sub topic 1
Starting from Get Data: how Power BI connectors work
Prerequisites
This chapter assumes you have these skills:
- You can open Power BI Desktop and find the Home ribbon.
- You can work with Excel tables and CSV files.
- You know what tables, rows, columns, and data types are.
You do not need to know the M language yet. Later chapters introduce it as needed.
What a connector is
A connector is a component that knows how to talk to one kind of data source. The Excel connector reads workbooks. The Text/CSV connector reads delimited text. The SharePoint connectors read files and lists from SharePoint Online.
Each connector does three jobs:
- It asks for the location of the data, such as a file path or a site URL.
- It asks for credentials, if the source needs them.
- It returns the data as a table that Power Query can shape.
The connector does not clean your data. It only gets the data into a table. Cleaning comes after that, in Power Query.
The Get Data flow
When you choose Home > Get data, Power BI shows a list of connectors grouped by category. The ones used in this tutorial are Excel workbook, Text/CSV, SharePoint folder, and SharePoint Online list.
The flow is the same for each one:
- Pick a connector and enter the location.
- Sign in or confirm credentials when prompted.
- Choose what to load in the Navigator window.
- Select Load to send the data straight to the model, or Transform Data to open Power Query Editor first.
For files you rarely want to load immediately. Choose Transform Data so you can check headers and data types before the data reaches your model.
What the connector writes for you
Every choice you make in the dialogs becomes a step in a Power Query query. The first step is usually named Source, and it holds the connector call. Here is the Source step for a local Excel workbook, followed by the navigation and type steps:
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 step by step:
Excel.Workbook(File.Contents(...), true, true)is the connector call.File.Contentsreads the file as binary.Excel.Workbookturns that binary into a table listing everything in the workbook. The twotruevalues tell it to use the first row as headers and to delay type detection.Source{[Item = "Sales", Kind = "Table"]}[Data]is the navigation step. It picks the row for the table namedSalesand takes itsDatacolumn.Table.TransformColumnTypessets the data type of each column you name.
The Navigator you used in the dialog produced the second line. You can always read and edit these steps later.
Connectors and credentials
Connecting to a source creates a stored credential for it. Power BI Desktop keeps credentials per data source, not per query. If two queries read from the same SharePoint site, they share one credential.
Credentials matter again when you publish. A report that loads in Desktop can still fail to refresh in the Power BI service if the service has no valid credential for each source. Chapters 12 and 13 cover this.
Common errors at this stage
| Symptom | Likely cause |
|---|---|
| Navigator shows no tables for an Excel file | The data is a plain range, not an Excel table. Pick the sheet, or format the range as a table. |
| "The file is in use" or access denied | Another process has the file locked, or your account cannot read it. |
| Credential prompt appears repeatedly | The stored credential is for a different path or account. Clear it under **File > Options and settings > Data source settings**. |
Exercise
You connect to a workbook and the Navigator lists both a sheet named Sales and a table named Sales. Which one should you prefer, and where in the query does your choice appear?
Show answer
Prefer the table when one exists, because its columns and boundaries are defined and it grows with new rows. Your choice appears in the navigation step right after Source, where Kind is "Table" for a table and "Sheet" for a sheet.
Exercise
What are the two options at the bottom of the Navigator, and when would you pick the second one?
Show answer
The options are Load and Transform Data. Pick Transform Data when the data needs checking or cleaning, such as promoting headers or setting column types, before it enters the model.