Chapter 2 of 12

Getting Data

Connect Power BI to various data sources — Excel, CSV, SQL Server, Web, APIs, and manage data connections.

Meritshot31 min read
Power BIData SourcesConnectorsImportDirectQuery
All Power BI Chapters

Getting Data

Every Power BI project begins with data. Power BI provides over 200 native connectors that let you connect to virtually any data source — from simple Excel files on your desktop to massive cloud data warehouses. Understanding how to connect to data sources, choose the right connection mode, and manage credentials and privacy settings is a critical skill for any Power BI developer.

In this chapter, you will learn how to connect to the most common data sources, understand the differences between Import, DirectQuery, and Live Connection modes, manage data source settings and privacy levels, use parameters for dynamic connections, and configure incremental refresh for large datasets.


Data Sources Overview

Power BI organizes its 200+ connectors into several categories. When you click Home → Get Data, you will see these categories in the left panel of the Get Data dialog.

Categories of Data Sources

CategoryExamplesDescription
FileExcel, CSV, Text, JSON, XML, PDF, Parquet, SharePoint FolderLocal or network files containing structured data
DatabaseSQL Server, PostgreSQL, MySQL, Oracle, IBM Db2, SAP HANA, Amazon Redshift, SnowflakeRelational and analytical databases
Power PlatformDataverse, Dataflows, Power BI Datasets (Semantic Models)Microsoft Power Platform services
AzureAzure SQL Database, Azure Synapse Analytics, Azure Blob Storage, Azure Data Lake Storage, Azure Cosmos DB, Azure DatabricksMicrosoft Azure cloud services
Online ServicesSharePoint Online List, Microsoft Exchange Online, Dynamics 365, Salesforce, Google Analytics, Adobe Analytics, GitHub, ZendeskSaaS applications and cloud services
OtherWeb, OData Feed, ODBC, OLE DB, R Script, Python Script, Blank Query, Spark, FHIR, Active DirectoryMiscellaneous and custom connectors

Most Common Connectors

In everyday work, you will use a handful of connectors most frequently:

  1. Excel Workbook — The most common starting point for many analysts
  2. CSV / Text File — Simple flat files with delimiter-separated values
  3. SQL Server — Microsoft's relational database, widely used in enterprise environments
  4. Web — Scraping data from web pages or calling REST APIs
  5. SharePoint Online List — Accessing data stored in SharePoint lists
  6. Folder — Combining multiple files from a directory into a single table
  7. Power BI Dataflows — Reusing centrally defined data preparation logic
  8. Azure SQL Database — Cloud-hosted SQL Server databases
  9. OData Feed — Consuming standardized API endpoints
  10. Dataverse — Microsoft's low-code data platform (formerly Common Data Service)

Import vs DirectQuery vs Live Connection

One of the most important decisions you make when connecting to a data source is the connection mode. Power BI offers three modes, each with distinct trade-offs.

Comparison Table

FeatureImportDirectQueryLive Connection
Data LocationData is loaded into Power BI's in-memory engine (VertiPaq)Data remains in the source; queries are sent on demandData remains in the source (SSAS or Power BI Dataset)
Supported SourcesAll connectorsSelected connectors (SQL Server, Azure SQL, Synapse, Oracle, SAP, etc.)SQL Server Analysis Services (SSAS), Power BI Datasets
Data FreshnessAs of last refreshReal-time (queries the source live)Real-time
PerformanceVery fast (in-memory)Depends on source query performanceDepends on source performance
DAX SupportFullFull (calculated tables not supported)Measures only (model is remote)
Power QueryFull transformation capabilitiesLimited (some transforms break query folding)Not available (model is predefined)
File SizeCan be large (data stored in .pbix)Small (no data stored locally)Small
Max Dataset Size (Service)1 GB (Pro), 100 GB (PPU), 400 GB (Premium)No local limit (source-dependent)Source-dependent
RefreshScheduled or on-demand refreshNo refresh needed (always live)No refresh needed
Composite ModelsCan combine with DirectQueryCan combine with ImportCannot combine with other modes
Ideal ForSmall to medium datasets (<1 GB); best performanceLarge datasets that cannot be imported; real-time needsConnecting to centralized enterprise semantic models

Import Mode (Default)

Import mode loads a snapshot of the data into Power BI's in-memory columnar engine (VertiPaq). This is the default and most commonly used mode.

How it works:

  1. Power BI executes queries against the source to extract data
  2. Data is compressed and stored in the .pbix file
  3. All visuals query the in-memory engine, which is extremely fast
  4. To get updated data, you must refresh the dataset (manually or on a schedule)

Advantages:

  • Fastest query performance (in-memory)
  • Full Power Query transformation support
  • Full DAX functionality
  • Works with all connectors
  • No dependency on source availability after loading

Disadvantages:

  • Data can become stale between refreshes
  • File size grows with data volume
  • Dataset size limits apply (1 GB for Pro)
  • Full data is stored in the file (security consideration)

When to use: Most scenarios, especially when your data is under 1 GB and does not need real-time freshness.

DirectQuery Mode

DirectQuery sends queries directly to the source database each time a user interacts with a visual.

How it works:

  1. Power BI generates DAX queries for each visual
  2. These are translated into the source's native query language (e.g., SQL)
  3. Queries are sent to the source, results are returned and rendered
  4. No data is stored in the .pbix file

Advantages:

  • Always shows current data (no refresh needed)
  • No dataset size limits
  • Small file size
  • Data stays in the source (security benefit)

Disadvantages:

  • Slower performance (depends on source speed)
  • Limited Power Query transformations (must maintain query folding)
  • Some DAX functions are not supported or perform poorly
  • Requires the source to be always available
  • Can put heavy load on the source database
  • Each user interaction generates queries

When to use: Large datasets (>1 GB) that cannot be imported; scenarios requiring real-time data; regulatory requirements to keep data in the source system.

Live Connection

Live Connection connects to an existing Analysis Services model (SSAS Tabular/Multidimensional) or a Power BI Dataset in the Service.

How it works:

  1. Power BI connects to a remote semantic model
  2. The data model (tables, relationships, measures) is defined in the remote source
  3. You build report visuals on top of the remote model
  4. No Power Query or local modeling is available

Advantages:

  • Leverages centralized enterprise models
  • Consistent metrics across all reports
  • No data duplication

Disadvantages:

  • Cannot modify the data model
  • Cannot use Power Query
  • Can only add measures (in some scenarios)
  • Fully dependent on the remote model's design

When to use: When your organization has a centralized Analysis Services model or a shared Power BI dataset that serves as the "single source of truth."

Choosing the Right Mode

Is your data < 1 GB and does not need real-time freshness?
├── YES → Use Import Mode
└── NO
    ├── Is the data in SSAS or an existing Power BI Dataset?
    │   ├── YES → Use Live Connection
    │   └── NO → Continue
    └── Does the data need to be real-time and/or is too large to import?
        ├── YES → Use DirectQuery
        └── NO → Use Import with incremental refresh

Connecting to Excel Files

Excel is the most common starting point for Power BI projects. Here is the step-by-step process.

Step-by-Step: Connect to an Excel File

  1. Open Power BI Desktop and click Home → Get Data → Excel Workbook (or Get Data → More → File → Excel Workbook)

  2. Browse to your Excel file using the file explorer dialog and click Open

  3. The Navigator dialog appears — This is a crucial dialog that shows you all available data objects in the Excel file:

    • Sheets — Each worksheet appears as an option (e.g., "Sheet1", "SalesData")
    • Tables — Any named Excel tables appear separately (e.g., "Table_Sales")
    • Named Ranges — Any defined named ranges also appear
  4. Select the data you want — Check the boxes next to the tables/sheets you want to load. A preview of the data appears on the right side.

  5. Choose Load or Transform Data:

    • Load — Immediately loads the data into the model as-is
    • Transform Data — Opens Power Query Editor so you can clean and shape the data first (recommended)

Best Practices for Excel Data

  • Use named Excel tables — Always format your data as a named table in Excel (Ctrl+T). Named tables are more reliable than raw sheets because they handle row additions dynamically.
  • Keep headers in the first row — Power BI expects column headers in row 1
  • Avoid merged cells — Merged cells cause import errors and data misalignment
  • Remove summary rows — If your sheet has total/subtotal rows, they will be imported as data rows. Remove them or handle them in Power Query.
  • Clean up the file — Remove empty columns, charts, and other non-data elements from the sheet
  • One table per sheet — Avoid putting multiple unrelated tables on a single sheet

Common Issues with Excel Files

IssueCauseSolution
Column headers are wrongFirst row is not the headerIn Power Query: Home → Use First Row as Headers
Extra blank rows at the bottomEmpty formatted cells in ExcelIn Power Query: Remove blank rows
Numbers stored as textExcel formatting issueIn Power Query: Change column type to Whole Number or Decimal
Dates showing as numbersSerial date formatIn Power Query: Change column type to Date
#N/A or #REF! errors in cellsExcel formula errorsIn Power Query: Replace errors or remove error rows
File path changedFile moved or renamedUpdate the data source path in Data Source Settings

Connecting to CSV/Text Files

CSV (Comma-Separated Values) and other delimited text files are another common data source.

Step-by-Step: Connect to a CSV File

  1. Click Home → Get Data → Text/CSV
  2. Browse to your CSV file and click Open
  3. Power BI displays a preview dialog with automatic detection of:
    • Delimiter — Comma, semicolon, tab, pipe, or custom delimiter
    • Data Type Detection — Based on first 200 rows
    • Encoding — UTF-8, UTF-16, ASCII, etc.
  4. Review the preview and adjust settings if needed
  5. Click Load or Transform Data

Key Settings for CSV Files

SettingDescriptionWhen to Change
File OriginCharacter encoding (UTF-8, Windows-1252, etc.)When you see garbled characters (é, ñ, ü rendering incorrectly)
DelimiterThe character that separates columnsWhen columns are not split correctly (e.g., semicolons used instead of commas)
Data Type DetectionHow Power BI detects column types"Based on first 200 rows" is default; change to "Based on entire dataset" for more accurate detection
Skip rowsNumber of rows to skip from the topWhen the file has metadata rows before the actual data

CSV vs Excel: Key Differences

FeatureCSVExcel
Multiple sheetsNo (single table per file)Yes
Data typesEverything is text (types are inferred)Data types are preserved
File sizeGenerally smallerCan be larger due to formatting
FormattingNoneCell formatting, formulas, charts
Unicode supportDepends on encodingFull support
Best forData exports, log files, API outputsStructured business data, reports

Connecting to SQL Server

SQL Server is the most common database connector used with Power BI, especially in enterprise environments.

Step-by-Step: Connect to SQL Server

  1. Click Home → Get Data → SQL Server (or Get Data → More → Database → SQL Server Database)

  2. Enter the Server name — This can be:

    • A server name: SERVERNAME
    • A named instance: SERVERNAME\INSTANCENAME
    • An IP address: 192.168.1.100
    • An Azure SQL server: yourserver.database.windows.net
  3. Enter the Database name (optional) — If left blank, you will see all databases on the server

  4. Expand Advanced options (optional) to set:

    • Command timeout — Maximum query wait time in minutes
    • SQL statement — Write a custom SQL query instead of selecting tables
    • Include relationship columns — Include foreign key columns
    • Navigate using full hierarchy — Show schema organization
    • Enable SQL Server Failover support — For high-availability setups
  5. Choose Data Connectivity mode:

    • Import (default) — Load data into Power BI
    • DirectQuery — Query the database live
  6. Click OK

  7. Authentication dialog — Choose the authentication method:

    • Windows — Uses your Windows login (Kerberos/NTLM)
    • Database — SQL Server username and password
    • Microsoft Account — For Azure SQL (Azure Active Directory)
  8. Navigator dialog — Browse the database structure:

    • Expand schemas (dbo, sales, hr, etc.)
    • Select tables and views
    • Preview data on the right side
    • Select multiple objects by checking their boxes
  9. Click Load or Transform Data

Writing Custom SQL Queries

Instead of selecting tables from the Navigator, you can write custom SQL in the advanced options:

SELECT
    o.OrderID,
    o.OrderDate,
    c.CustomerName,
    c.City,
    p.ProductName,
    p.Category,
    od.Quantity,
    od.UnitPrice,
    od.Quantity * od.UnitPrice AS LineTotal
FROM Orders o
INNER JOIN Customers c ON o.CustomerID = c.CustomerID
INNER JOIN OrderDetails od ON o.OrderID = od.OrderID
INNER JOIN Products p ON od.ProductID = p.ProductID
WHERE o.OrderDate >= '2025-01-01'

Advantages of custom SQL:

  • Pre-join tables to simplify the model
  • Filter data at the source (better performance)
  • Use SQL functions not available in Power Query
  • Reduce data volume before loading

Disadvantages:

  • Breaks query folding for subsequent Power Query steps
  • Harder to maintain than visual Power Query steps
  • Requires SQL knowledge
  • The query runs as a "black box" in Power Query

SQL Server Connection Tips

  • Always specify the database name — Avoids confusion when a server hosts multiple databases
  • Use views instead of tables — Database views can pre-filter and pre-join data, simplifying your model
  • Consider stored procedures — Use EXEC dbo.sp_GetSalesData for parameterized data extraction
  • Test your queries — Run custom SQL in SQL Server Management Studio (SSMS) first to verify results and performance
  • Use Windows authentication when possible — More secure and does not require storing passwords

Connecting to Web Data

Power BI can extract data from web pages, REST APIs, and online data sources using the Web connector.

Step-by-Step: Connect to a Web Page

  1. Click Home → Get Data → Web
  2. In the dialog, select Basic and enter the URL of the web page containing tabular data
  3. Click OK
  4. Authentication dialog — Select the appropriate method:
    • Anonymous — No credentials needed (public web pages)
    • Windows — Pass Windows credentials to the web server
    • Basic — Username and password (HTTP Basic Auth)
    • Web API — API key authentication
    • Organizational Account — OAuth2 / Microsoft Entra ID authentication
  5. The Navigator displays all tables detected on the web page
  6. Select the table(s) you want and click Load or Transform Data

Connecting to REST APIs

For REST APIs that return JSON data:

  1. Click Home → Get Data → Web
  2. Select Advanced to configure:
    • URL parts — Build the URL dynamically
    • HTTP request header parameters — Add headers like Authorization, Content-Type, Accept
  3. Enter the API endpoint URL (e.g., https://api.example.com/data)
  4. Add required headers:
Authorization: Bearer your-api-token-here
Content-Type: application/json
  1. Click OK
  2. Power BI will fetch the JSON response and open it in Power Query
  3. Use Power Query to parse the JSON structure:
    • Convert JSON records to a table
    • Expand nested columns
    • Rename columns as needed

Example: Fetching JSON from an API

When Power BI receives JSON data like:

{
  "results": [
    {"id": 1, "name": "Alice", "department": "Engineering"},
    {"id": 2, "name": "Bob", "department": "Marketing"},
    {"id": 3, "name": "Carol", "department": "Finance"}
  ],
  "total": 3
}

In Power Query, you would:

  1. The response loads as a Record — click on "results" to navigate into the list
  2. Click To Table to convert the list to a table
  3. Click the expand icon (double arrow) on the Column1 header to expand the records
  4. Select the fields you want (id, name, department) and click OK
  5. Rename and retype columns as needed

Web Connector Limitations

  • Power BI can only scrape data from HTML tables on web pages (not JavaScript-rendered content)
  • Complex websites with dynamic content may not work with the basic Web connector
  • APIs with pagination require custom M code or Power Query logic to fetch all pages
  • Rate limits on APIs may cause timeout errors during refresh

Connecting to Folders

The Folder connector is powerful for combining multiple files of the same structure into a single table.

Use Cases

  • Combining monthly sales reports stored as separate Excel files
  • Merging CSV log files from a directory
  • Consolidating regional data files into one dataset

Step-by-Step: Connect to a Folder

  1. Click Home → Get Data → More → File → Folder
  2. Enter or browse to the folder path (local, network share, or mapped drive)
  3. Click OK
  4. Power BI lists all files in the folder with metadata:
    • File name, extension, date modified, size, folder path
  5. Click Combine & Transform Data (recommended) or Combine & Load
  6. The Combine Files dialog appears:
    • Select a sample file to define the structure
    • Choose the sheet/table within each file (for Excel files)
    • Configure the delimiter (for CSV files)
  7. Click OK

Power BI automatically:

  • Creates a function to extract data from each file
  • Applies the function to all files in the folder
  • Appends all results into a single table
  • Adds a "Source.Name" column identifying which file each row came from

Important Notes

  • All files in the folder must have the same structure (same columns in the same order)
  • When new files are added to the folder, they are automatically included on the next refresh
  • You can filter files by name or extension in Power Query to exclude unwanted files
  • Subfolders are included by default — filter the "Folder Path" column to exclude them if needed

Data Source Settings

After connecting to data sources, you may need to update credentials, change file paths, or modify connection details.

Accessing Data Source Settings

From Power BI Desktop:

  1. Go to File → Options and settings → Data source settings
  2. You will see a list of all data sources used in the current file
  3. Select a source to:
    • Edit Permissions — Change credentials, privacy level, or encryption settings
    • Change Source — Update the file path, server name, or URL
    • Clear Permissions — Remove stored credentials (forces re-authentication)
    • Delete — Remove the data source reference

Changing Data Source Paths

When a file is moved or a server name changes:

  1. Open Data Source Settings (File → Options and settings → Data source settings)
  2. Select the data source
  3. Click Change Source
  4. Enter the new path, server name, or URL
  5. Click OK
  6. Refresh the data to verify the connection works

Alternative method: In Power Query Editor, click on the Source step in Applied Steps. Edit the file path or server name directly in the formula bar.

Managing Credentials

Credentials are stored per data source and per user. To update or change credentials:

  1. Open Data Source Settings
  2. Select the data source
  3. Click Edit Permissions
  4. Under Credentials, click Edit
  5. Choose the authentication type and enter new credentials
  6. Click Save

Tip: If you encounter "credentials are invalid" errors after a password change, clear the permissions and re-enter your credentials.


Privacy Levels

Privacy levels are a crucial but often confusing aspect of Power BI data connections. They control how data from different sources can be combined and whether query folding can send data between sources.

The Three Privacy Levels

Privacy LevelDescriptionExample Data Sources
PrivateData source contains sensitive data; no data from this source is sent to other sourcesEmployee salaries, medical records, financial data
OrganizationalData source contains data visible within the organization but not publiclyInternal sales data, CRM data, SharePoint lists
PublicData source contains publicly available data; can be freely combined with any sourceCensus data, public APIs, web-scraped data

How Privacy Levels Work

When you combine data from multiple sources (e.g., merging an Excel file with a SQL Server table), Power BI checks the privacy levels to determine if the combination is allowed:

Source ASource BResult
PublicPublicAllowed
PublicOrganizationalAllowed
PublicPrivateBlocked
OrganizationalOrganizationalAllowed
OrganizationalPrivateBlocked
PrivatePrivateBlocked (from different sources)

Common Privacy Level Errors

Error: "Formula.Firewall: Query references other queries or steps, so it may not directly access a data source."

This error occurs when Power BI's privacy firewall blocks data from being sent between sources.

Solutions:

  1. Set appropriate privacy levels — In Data Source Settings, edit permissions for each source and set the correct privacy level
  2. Ignore privacy levels (development only) — Go to File → Options and settings → Options → Current File → Privacy, select "Ignore the Privacy levels and potentially improve performance." Warning: Only use this during development. It bypasses all privacy protections.
  3. Restructure your queries — Avoid mixing source access and transformations in a single query. Use staging queries that load data first, then reference them in transformation queries.

Setting Privacy Levels

  1. Go to File → Options and settings → Data source settings
  2. Select a data source and click Edit Permissions
  3. Under Privacy Level, select the appropriate level from the dropdown
  4. Click OK

Parameters

Power Query parameters allow you to create dynamic, reusable values that can be used in data source paths, filter conditions, and other query settings.

Why Use Parameters?

  • Dynamic file paths — Change the data source path without editing queries
  • Environment switching — Switch between development, testing, and production databases
  • User-driven filtering — Let users specify a date range or region before loading data
  • Template files — When users open a .pbit template, they are prompted to enter parameter values

Creating a Parameter

  1. In Power Query Editor, click Home → Manage Parameters → New Parameter
  2. Configure the parameter:
SettingDescriptionExample
NameA descriptive nameServerName
DescriptionOptional explanation"The SQL Server to connect to"
RequiredWhether the parameter must have a valueYes
TypeData type (Text, Decimal Number, Date, etc.)Text
Suggested ValuesAny value, list of values, or queryList of values
Default ValueThe initial valueprod-server.database.windows.net
Current ValueThe currently active valuedev-server.database.windows.net
  1. Click OK

Using Parameters in Data Sources

Once created, you can use parameters in your data source connections:

Example: Parameterized SQL Server connection

In Power Query, modify the Source step to use the parameter:

let
    Source = Sql.Database(ServerName, DatabaseName),
    dbo_Sales = Source{[Schema="dbo", Item="Sales"]}[Data]
in
    dbo_Sales

Where ServerName and DatabaseName are parameters.

Example: Parameterized file path

let
    Source = Excel.Workbook(File.Contents(FilePath & "\SalesData.xlsx"), null, true),
    Sheet1 = Source{[Item="Sheet1", Kind="Sheet"]}[Data]
in
    Sheet1

Where FilePath is a parameter like C:\Data\2025.

Switching Parameter Values

To change parameter values:

  1. In Power Query Editor, click Home → Manage Parameters → Edit Parameters
  2. Update the current value for each parameter
  3. Click OK
  4. Refresh the queries

Or simply click on the parameter in the Queries pane and edit the Current Value in the parameter settings panel.


Incremental Refresh

Incremental refresh is a feature that optimizes data refresh for large datasets by only refreshing the most recent data, rather than reloading the entire dataset every time.

Why Use Incremental Refresh?

Without incremental refresh, a dataset with millions of rows must be fully reloaded on every refresh. This causes:

  • Long refresh times (minutes or hours)
  • Heavy load on the source database
  • High memory consumption
  • Risk of timeout errors

With incremental refresh:

  • Only new and changed data is refreshed
  • Historical data is cached and not re-queried
  • Refresh times are dramatically reduced
  • Source database load is minimized

How It Works

Incremental refresh divides your data into two ranges based on date:

  1. Archive range — Historical data that rarely changes (e.g., data older than 30 days). This data is loaded once and not refreshed again.
  2. Incremental range — Recent data that may change (e.g., the last 30 days). This data is refreshed on every cycle.
[========= Archive (cached) =========][== Incremental (refreshed) ==][New]
   2023         2024        Jan-Feb 2026      Mar 2026              Today

Prerequisites

  • The table must have a Date/DateTime column that defines the partition boundary
  • Two reserved parameters must be created in Power Query:
    • RangeStart (type: Date/Time)
    • RangeEnd (type: Date/Time)
  • The data source must support query folding so the date filter is pushed to the source
  • The dataset must be published to the Power BI Service (incremental refresh does not run in Desktop)

Setting Up Incremental Refresh

Step 1: Create the required parameters

  1. In Power Query, create a parameter named RangeStart:

    • Type: Date/Time
    • Current Value: a sample date (e.g., 1/1/2025 12:00:00 AM)
  2. Create a parameter named RangeEnd:

    • Type: Date/Time
    • Current Value: a date after RangeStart (e.g., 4/1/2025 12:00:00 AM)

Step 2: Filter the table using the parameters

  1. Select your date column in Power Query
  2. Apply a custom filter:
    • Greater than or equal to RangeStart
    • AND less than RangeEnd

The resulting M code will look like:

= Table.SelectRows(PreviousStep, each [OrderDate] >= RangeStart and [OrderDate] < RangeEnd)

Step 3: Configure incremental refresh policy

  1. In Power BI Desktop, right-click the table in the Fields pane

  2. Select Incremental refresh and real-time data

  3. Configure:

    • Archive data starting — How far back to keep historical data (e.g., 3 years)
    • Incrementally refresh data starting — How far back to refresh on each cycle (e.g., 30 days)
    • Detect data changes (optional) — Use a column like LastModified to detect changed rows in the archive range
    • Only refresh complete days/periods (optional) — Wait until a full day/period is complete before refreshing
  4. Click Apply

Step 4: Publish and configure refresh

  1. Publish the report to the Power BI Service
  2. In the Service, configure a scheduled refresh
  3. The first refresh loads all historical data (may take a long time)
  4. Subsequent refreshes only process the incremental range

Incremental Refresh Summary Table

SettingDescriptionExample Value
Archive periodHow far back to retain data3 years
Incremental periodHow far back to refresh30 days
Detect changes columnA column to identify changed rowsLastModifiedDate
Complete periodsOnly refresh after period endsYes (avoid partial day data)

Common Connection Errors

When connecting to data sources, you may encounter various errors. Here is a troubleshooting guide for the most common issues:

ErrorLikely CauseSolution
"We couldn't find any data formatted as a table"Excel file has no named tables or structured dataFormat data as a table in Excel (Ctrl+T) or use Power Query to promote headers
"Unable to connect to the server"Server name is wrong, server is down, or firewall is blockingVerify server name, check server status, confirm firewall rules allow port 1433 (SQL Server)
"Login failed for user"Wrong username/password or insufficient permissionsVerify credentials, check that the user has SELECT permissions on the required tables
"The credentials provided are invalid"Stored credentials have expired or password changedClear permissions in Data Source Settings and re-enter credentials
"A firewall is blocking the connection"Network firewall or Windows Firewall blocking outbound connectionsContact IT to open the required port; for Azure SQL, add your IP to the server's firewall rules
"The driver was not found"Missing ODBC or OLE DB driver for the data sourceDownload and install the required driver (e.g., MySQL ODBC driver, Oracle client)
"Query timeout expired"Query takes too long to executeIncrease timeout in advanced options; optimize the source query; use a smaller date range
"Access to the resource is forbidden"OAuth token expired or insufficient API permissionsRe-authenticate; check API permissions and scopes
"Out of memory"Dataset is too large for available RAMFilter data at the source; increase system RAM; consider DirectQuery
"Formula.Firewall"Privacy level conflict between sourcesSet correct privacy levels for each source or restructure queries
"The column 'X' was not found"Source schema has changed (column renamed or removed)Update Power Query to reflect the new schema; check source for changes
"Data source error: Could not find file"File has been moved, renamed, or deletedUpdate file path in Data Source Settings or Power Query Source step
"Expression.Error: We cannot apply operator + to types Text and Number"Data type mismatch in a transformation stepConvert columns to the correct type before performing operations
"Connection timed out"Network issue or source server is overloadedRetry; check network connectivity; contact the DBA to check server load

General Troubleshooting Steps

  1. Check the error message carefully — It usually indicates the root cause
  2. Test the connection outside Power BI — Use SSMS for SQL Server, a browser for web URLs, or file explorer for file paths
  3. Verify credentials — Clear and re-enter in Data Source Settings
  4. Check network connectivity — Can you ping the server? Is VPN connected?
  5. Update Power BI Desktop — Some connector issues are fixed in newer versions
  6. Check the Power BI community forums — Most errors have been encountered and solved by others
  7. Review the Privacy levels — This is the most common cause of Formula.Firewall errors

Practice Exercises

Exercise 1: Connect to an Excel File

Objective: Practice loading data from Excel.

Instructions:

  1. Create an Excel file called Products.xlsx with a table containing:
    • ProductID (1–20)
    • ProductName (various product names)
    • Category (Electronics, Clothing, Food, Furniture)
    • Price (various decimal numbers)
    • InStock (TRUE/FALSE)
  2. Save the file and open Power BI Desktop
  3. Connect to the Excel file using Get Data → Excel Workbook
  4. Preview the data in the Navigator dialog
  5. Click Transform Data to open Power Query Editor
  6. Verify that data types are correctly detected (especially Price as Decimal and InStock as Boolean)
  7. Fix any data type issues, then click Close & Apply
  8. Create a bar chart showing average Price by Category
  9. Save the report

Exercise 2: Connect to a CSV File

Objective: Practice handling CSV data with different delimiters and encodings.

Instructions:

  1. Create a CSV file called sales_log.csv with semicolons as delimiters:
Date;Region;Amount;Quantity
2025-01-15;North;1250.50;10
2025-01-16;South;890.25;7
2025-01-17;East;1540.00;12
2025-01-18;West;2100.75;15
2025-01-19;North;960.00;8
  1. Connect to the CSV file in Power BI
  2. Verify that Power BI detects the semicolon delimiter
  3. If not, manually change the delimiter in the preview dialog
  4. Load the data and create a line chart showing Amount by Date with Region as the Legend
  5. Save the report

Exercise 3: Connect to Web Data

Objective: Practice extracting tables from web pages.

Instructions:

  1. In Power BI Desktop, click Get Data → Web
  2. Enter a URL for a web page that contains a table (e.g., a Wikipedia page with statistical tables)
  3. Select Anonymous authentication
  4. Browse the detected tables in the Navigator
  5. Select a table and click Transform Data
  6. Clean the data in Power Query:
    • Remove unnecessary columns
    • Fix data types
    • Remove header/footer rows if present
  7. Load the data and create a visual

Exercise 4: Import vs DirectQuery Comparison

Objective: Understand when to use Import vs DirectQuery.

Instructions: For each scenario below, recommend Import, DirectQuery, or Live Connection, and explain your reasoning:

  1. A 500 MB sales dataset refreshed weekly from a SQL Server
  2. A 50 GB transaction database where users need to see real-time data
  3. An enterprise Analysis Services model shared across 20 reports
  4. A small CSV file with 1,000 rows exported from a web application
  5. A 2 GB dataset that changes every 5 minutes and is stored in Azure SQL
  6. A Power BI dataset already published in the Service that other teams want to reuse

Exercise 5: Create Parameters

Objective: Practice creating and using Power Query parameters.

Instructions:

  1. Open the report from Exercise 1 (or create a new one)
  2. Open Power Query Editor
  3. Create a parameter called MinPrice of type Decimal Number with a default value of 0
  4. Create a parameter called SelectedCategory of type Text with a list of suggested values: Electronics, Clothing, Food, Furniture
  5. Modify your Products query to filter:
    • Price greater than or equal to MinPrice
    • Category equals SelectedCategory
  6. Test by changing parameter values and refreshing the preview
  7. Close & Apply and verify the filtered data in your report

Exercise 6: Troubleshoot Connection Errors

Objective: Practice diagnosing and solving common connection errors.

Instructions: For each error scenario below, identify the cause and write the steps to fix it:

  1. You moved your Excel file from C:\Data\Sales.xlsx to D:\Reports\Sales.xlsx and now the refresh fails
  2. Your SQL Server connection fails with "Unable to connect" but you could connect yesterday
  3. You are combining data from an Excel file and a SQL Server table, and you get a Formula.Firewall error
  4. Your CSV file loads correctly but all numbers show as text

Summary

In this chapter, you learned how to connect Power BI to various data sources and manage those connections effectively:

  • Power BI offers 200+ connectors organized into categories: Files, Databases, Power Platform, Azure, Online Services, and Other
  • Three connection modes serve different needs:
    • Import — Best performance, loads data into memory, requires refresh
    • DirectQuery — Real-time data, queries the source live, depends on source performance
    • Live Connection — Connects to existing Analysis Services or Power BI semantic models
  • Excel connections use the Navigator dialog to select sheets, tables, or named ranges
  • CSV connections require attention to delimiter, encoding, and data type detection
  • SQL Server connections support Windows/Database/Microsoft authentication and custom SQL queries
  • Web connections can extract HTML tables and consume REST APIs with various authentication methods
  • Folder connections combine multiple files of the same structure into a single table
  • Data Source Settings let you manage credentials, change paths, and set privacy levels
  • Privacy Levels (Private, Organizational, Public) control how data from different sources can be combined
  • Parameters enable dynamic, reusable connections that can switch between environments or accept user input
  • Incremental Refresh optimizes large dataset refreshes by only processing new and changed data
  • Common errors can usually be resolved by checking credentials, network connectivity, privacy levels, and data source paths

In the next chapter, you will learn how to use Power Query to clean, transform, and shape your data before loading it into the data model.