Introduction to Power BI Data Sources

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 13 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Introduction to Power BI Data Sources

Welcome to the first major step in your data journey. Before you can build a single chart, calculate a profit margin, or design a dashboard, you need data. In the world of Power BI, this isn't just about opening a file; it is about establishing a reliable, secure, and efficient pipeline between your raw information and your analytical environment.

Power BI is famous for its versatility. Whether your data lives in a dusty Excel spreadsheet on your local drive, a massive SQL Server database in a data center, or a cloud-based service like Salesforce or Google Analytics, Power BI provides the tools to bring that data together. However, "connecting to data" is more than just clicking a button. It involves making strategic decisions about how that data is stored, how often it refreshes, and how much of it you actually need to bring into your model.

In this lesson, we are going to explore the vast landscape of Power BI data sources. We will look at the different types of connectors available, the critical differences between connectivity modes like Import and DirectQuery, and how to handle the security and authentication requirements that often act as hurdles for beginners. By the end of this guide, you will have a clear understanding of how to lay a solid foundation for any reporting project.


Not read yet

The "Get Data" Experience

When you first open Power BI Desktop, the "Get Data" button is your gateway. Clicking it reveals a categorized list of over 100 connectors. These connectors are essentially pre-built scripts that know exactly how to talk to specific systems. Instead of you having to write complex code to authenticate with an API or navigate a database schema, the connector handles the heavy lifting.

The connectors are organized into several logical groups:

  • File: Excel workbooks, Text/CSV, XML, JSON, and even Folders.
  • Database: SQL Server, Oracle, IBM DB2, MySQL, PostgreSQL, and more.
  • Power Platform: Power BI datasets, Dataflows, and Dataverse.
  • Azure: Azure SQL Database, Azure Analysis Services, and Azure Blob Storage.
  • Online Services: SharePoint, Salesforce, Dynamics 365, and Google Analytics.
  • Other: Web pages, OData feeds, Active Directory, and blank queries for custom M code.

While the specific details for each connector vary, the workflow is almost always the same: you identify the source, provide credentials, select the specific tables or items you want, and then decide whether to load the data directly or transform it first in Power Query.


Not read yet

Understanding Connectivity Modes

One of the most important decisions you will make when connecting to data is choosing the connectivity mode. This choice affects the performance of your report, the freshness of your data, and the size of your Power BI file.

Import Mode

Import mode is the default and most common way to bring data into Power BI. When you use Import mode, Power BI takes a snapshot of the data from the source and stores it inside the Power BI Desktop file (.pbix). This data is compressed using the VertiPaq engine, which is incredibly efficient at handling large volumes of information.

Pros of Import Mode:

  • Blazing Fast Performance: Because the data is stored in the local memory of the machine (or the Power BI service), interactions with visuals are nearly instantaneous.
  • Full Functionality: You have access to the full range of Power Query transformations and the entire DAX (Data Analysis Expressions) library.
  • Multi-Source Integration: You can combine data from an Excel file, a SQL database, and a Web API all into a single model.

Cons of Import Mode:

  • Data Latency: The data is only as fresh as the last refresh. If the source data changes, you won't see those changes until the next scheduled or manual refresh.
  • File Size Limits: There is a limit on the size of the dataset (1GB for Pro licenses, though this is compressed size).

DirectQuery

DirectQuery is the opposite of Import. Instead of taking a copy of the data, Power BI stays connected to the source in real-time. Every time a user interacts with a visual (like clicking a slicer), Power BI sends a query directly to the source database to fetch the necessary results.

Pros of DirectQuery:

  • Real-Time Data: You are always looking at the most current data available in the source system.
  • Large Datasets: If your source database has billions of rows that exceed Power BI’s storage limits, DirectQuery allows you to report on that data without moving it.

Cons of DirectQuery:

  • Slower Performance: The speed of your report is entirely dependent on the speed of the source database. If the database is busy or slow, your visuals will lag.
  • Limited Transformations: Many Power Query transformations are unavailable because they cannot be "translated" into the native language of the source database (like SQL).

Callout: Import vs. DirectQuery Think of Import like downloading a movie to your tablet. You can watch it anywhere, it starts instantly, and you have full control, but if the director releases an "Extended Cut," you have to download it again. Think of DirectQuery like streaming a movie. You don't take up space on your device, and you're always seeing the latest version, but if your internet (or the server) is slow, the movie will buffer.


Not read yet

Connecting to File-Based Sources

Files are the bread and butter of many organizations. Even in the age of big data, much of the world's business logic still lives in Excel files and CSVs.

Excel Workbooks

Connecting to Excel is straightforward, but there is a "best practice" way to do it. When you connect to an Excel file, Power BI allows you to select either a Sheet or a Table.

It is highly recommended to format your data as a "Table" within Excel (using Ctrl+T) before connecting. Tables provide a named range that Power BI can target precisely. If you connect to a Sheet, Power BI will often import empty rows or columns that happen to have formatting on them, leading to unnecessary data cleaning steps later.

CSV and Text Files

CSVs are popular because they are lightweight and universal. When connecting to a CSV, Power BI uses a "delimiter" (usually a comma or semicolon) to separate the data. One thing to watch out for is the File Origin (encoding). If you see strange characters in your text, you may need to change the encoding to UTF-8 or another standard to ensure the text displays correctly.

Connecting to a Folder

This is one of the most powerful features for automation. Imagine you receive a monthly sales report as a CSV file. Instead of connecting to each file individually, you can connect to the Folder.

Power BI will look at all the files in that folder and "combine" them into a single table. As long as the files have the same structure (columns), you can simply drop a new file into that folder next month, hit "Refresh" in Power BI, and your report will automatically include the new data.


Not read yet

Connecting to Relational Databases

For most enterprise-level reporting, you will be connecting to relational databases like SQL Server. This requires a bit more technical setup than a simple file connection.

The Connection Dialog

When you connect to SQL Server, you will be asked for:

  1. Server Name: The network address or name of the server.
  2. Database Name (Optional): While optional, it is better to specify the database to narrow down the list of tables you have to look through.
  3. Authentication: You can use your Windows credentials (if you are on a corporate network) or a specific Database username and password.

SQL Statements vs. Table Selection

Power BI gives you the option to write a SQL statement directly in the connection box. While this is tempting for SQL experts, it is often better to select the tables from the Navigator list and use Power Query for filtering.

Why? Because of a concept called Query Folding. If you select tables via the UI, Power Query can "fold" your transformation steps back into a single SQL query that the database executes. If you write a custom SQL statement, you often "break" the fold for any subsequent steps, forcing Power BI to do the heavy lifting locally.

Note: Always aim for Query Folding. It pushes the computational work to the database server, which is usually much more powerful than your local machine.


Not read yet

The Power Query Engine and M Language

Behind every connection you make is a language called M. You don't necessarily need to be a programmer to use Power BI, but understanding that M exists will help you troubleshoot connection issues.

When you connect to a source, Power BI generates an M script. You can see this by opening the Advanced Editor in the Power Query window. A typical connection to a SQL database looks like this:

let
    Source = Sql.Database("ServerName", "DatabaseName"),
    dbo_SalesTable = Source{[Schema="dbo", Item="SalesTable"]}[Data],
    FilteredRows = Table.SelectRows(dbo_SalesTable, each [SalesAmount] > 100)
in
    FilteredRows

Breakdown of the Code:

  • Sql.Database: This is the function that initiates the connection.
  • Source: This variable holds the entire database structure (all tables and views).
  • dbo_SalesTable: This step drills down into a specific table.
  • FilteredRows: This is a transformation step. Because this is a SQL source, Power Query will try to combine this filter with the initial request so the database only sends back rows where SalesAmount is greater than 100.

Not read yet

Cloud Services and APIs

The modern business runs on SaaS (Software as a Service). Power BI has dedicated connectors for many of these, such as Salesforce, Adobe Analytics, and Zendesk.

Authentication and Privacy

When connecting to cloud services, you will usually be redirected to a login page for that service. Power BI uses OAuth2 for most of these connections, meaning it doesn't store your password; instead, it receives a "token" that grants it permission to read your data.

Data Privacy Levels

This is a common "gotcha" for new users. When you combine data from two different sources (e.g., a local Excel file and a SQL database), Power BI asks you to define Privacy Levels:

  • Public: Anyone can see the data.
  • Organizational: Only people within your company can see it.
  • Private: Only you can see it.

Power BI uses these levels to prevent data from one source being sent to another source during a query. For example, if you have a list of "Secret Project Names" in Excel and you use them to filter a "Public SQL Database," Power BI needs to know if it's safe to send those secret names to the SQL server as part of the query.

Warning: Setting privacy levels to "Ignore" can speed up development, but it is a security risk in a production environment. Always categorize your sources correctly to prevent data leakage.


Not read yet

Comparison of Common Data Sources

Source Type Best For Connectivity Mode Refresh Capability
Excel Ad-hoc analysis, manual data entry Import Manual/Scheduled (via Gateway)
SQL Server Enterprise data, large volumes Import or DirectQuery Scheduled or Real-time
Web (API) Real-time public data, SaaS info Import Scheduled
Folder Monthly/Weekly recurring reports Import Scheduled (via Gateway)
Azure SQL Cloud-native applications Import or DirectQuery Scheduled/Real-time (No Gateway needed)

The Role of the Data Gateway

Once you have built your report in Power BI Desktop and published it to the Power BI Service (the cloud), you face a new challenge: How does the cloud talk to your local data?

If your data is stored on a local server or a personal computer, the Power BI Service cannot "reach" through your company's firewall to grab it. This is where the On-Premises Data Gateway comes in.

The Gateway acts as a bridge. It sits on a server inside your network, receives requests from the Power BI Service, fetches the data from the local source, and securely sends it back to the cloud.

Two Types of Gateways:

  1. Standard Mode: Installed on a server. Multiple users can use it. This is the professional choice for corporate reporting.
  2. Personal Mode: Installed on your own laptop. Only you can use it. If your laptop is turned off, the data won't refresh. Avoid this for critical business reports.

Not read yet

Step-by-Step: Connecting to a SQL Server Database

To give you a practical feel for the process, let's walk through a standard connection to a SQL Server database.

  1. Open Power BI Desktop and click on Get Data from the Home ribbon.
  2. Select SQL Server from the list of common sources.
  3. Enter the Server Name. If you are practicing on your own machine and have SQL Express installed, this might be localhost or .\SQLEXPRESS.
  4. Select the Data Connectivity Mode. Choose Import for this exercise to ensure full functionality.
  5. Expand Advanced Options (Optional). Here you could paste a SQL statement, but for now, leave it blank. Click OK.
  6. Authentication. If you are on a work network, "Windows" is usually the correct choice. Click Connect.
  7. The Navigator Window. This window shows you every table and view in the database. Check the boxes next to the tables you want (e.g., FactSales, DimProduct, DimDate).
  8. Preview the Data. Clicking a table name allows you to see a preview on the right. This is helpful to ensure you've picked the right one.
  9. Transform Data vs. Load.
    • Clicking Load brings the data directly into your model.
    • Clicking Transform Data opens the Power Query Editor. Always choose Transform Data. It is very rare that a database table is perfectly clean and ready for reporting without at least one or two adjustments.

Not read yet

Best Practices for Data Connections

Connecting to data is easy; connecting to data well is an art. Follow these industry standards to ensure your reports are maintainable and performant.

1. The "Need to Know" Basis (Column Selection)

Do not import every column from a table just because it's there. Every column you add increases the memory footprint of your model. If you have a table with 100 columns but you only use 5 for your report, you are wasting 95% of the resources for that table. Use the "Choose Columns" feature in Power Query to remove what you don't need immediately after connecting.

2. Use Parameters for Server Names

Hardcoding a server name into your connection is a recipe for headaches. If your IT department moves the database to a new server, you would have to open every Power BI file and manually change the connection string.

Instead, create a Parameter for the Server Name. This allows you to change the source in one place, or even change it after the report is published to the web without re-downloading the .pbix file.

3. Rename Steps and Tables Immediately

When you connect to a database, the table might be named something cryptic like TBL_FIN_SALES_2023_v2. Rename it to something user-friendly like Sales immediately. Your end-users (and your future self) will thank you when they are trying to find fields for their charts.

4. Be Mindful of Data Types

Power BI is usually good at guessing data types (e.g., identifying a date or a number), but it's not perfect. Always verify your data types during the connection phase. A "Zip Code" might look like a number, but it should be treated as text so that leading zeros aren't dropped.

Tip: If you are connecting to a CSV file, Power BI will add a step called "Changed Type" automatically. Always check this step; it often gets it wrong for ID numbers or specific date formats.


Not read yet

Common Pitfalls and How to Avoid Them

Even experts run into trouble with data connections. Here are the most frequent mistakes and how to steer clear of them.

The "Hardcoded Path" Error

The Scenario: You connect to an Excel file on your Desktop (C:\Users\YourName\Desktop\Data.xlsx). You publish the report. The refresh fails. The Fix: The Power BI Service cannot see your C: drive. Always store shared files on a network drive, SharePoint, or OneDrive. If using SharePoint/OneDrive, use the "Web" connector and the file's URL rather than the local file path.

Mixing Privacy Levels

The Scenario: You get a "Formula.Firewall" error saying that data sources cannot be combined. The Fix: This happens when Power BI thinks you are trying to send private data to a public source. Go to File > Options and settings > Options > Privacy and ensure your sources are categorized correctly. For development, you can select "Always ignore Privacy Level settings," but remember to fix it for production.

Over-Reliance on DirectQuery

The Scenario: Your report is painfully slow. Every time someone clicks a button, a little spinner appears for 10 seconds. The Fix: You likely used DirectQuery when Import would have sufficed. Only use DirectQuery if you truly need second-by-second updates or if your data is so massive it literally won't fit in an Import model. For 90% of business cases, Import is the better choice.

Credential Expiration

The Scenario: A report that has worked for months suddenly stops refreshing. The Fix: Check the credentials in the Power BI Service. If you used your personal password and recently changed it for your Windows login, the connection will break. Using "Service Accounts" with non-expiring passwords for database connections is the standard solution in professional environments.


Not read yet

Advanced Connection Scenarios

Connecting to Web APIs

Many modern tools don't have a direct "button" in Power BI, but they do have an API. You can use the Web connector to reach these. Usually, this involves a URL and an API Key.

In Power Query, you would use Json.Document(Web.Contents("https://api.example.com/data")). This returns a JSON object that you can then "expand" into a table. This is a bit more advanced but opens up the entire internet as a potential data source.

Power BI Datasets as a Source

One of the best ways to work in a large organization is to use Power BI Datasets as a source. Instead of everyone connecting to the same SQL database and reinventing the wheel, one person (the "Data Architect") creates a single, perfect, "Golden Dataset" and publishes it.

Everyone else then connects to that Power BI Dataset instead of the raw SQL. This ensures that everyone is using the same definitions for "Profit" or "Active Customer," creating a "single version of the truth."

Callout: The "Golden Dataset" Strategy By separating the Data Model (the connection, relationships, and measures) from the Report (the visuals), you make your system much easier to maintain. If a calculation changes, you fix it in one dataset, and every report connected to it updates automatically.


Not read yet

Summary and Key Takeaways

Getting data into Power BI is the foundational skill upon which everything else is built. If your connection is weak, slow, or disorganized, your final report will suffer regardless of how beautiful the charts are.

As you move forward, keep these key takeaways in mind:

  • Choose the Right Mode: Use Import for speed and features; use DirectQuery for massive or real-time data.
  • Prioritize Tables over Sheets: When using Excel, always format your data as a Table to avoid importing "junk" rows and columns.
  • Think About the Gateway: If your data is on-premises, you will need a Standard Data Gateway to keep the data fresh once it is published to the cloud.
  • Query Folding is Your Friend: Let the database do the hard work. Avoid custom SQL queries in the connection box unless absolutely necessary, as they often prevent Power Query from optimizing the request.
  • Security Matters: Be intentional with your Privacy Levels and authentication methods. Use Service Accounts for production reports to avoid refresh failures due to password changes.
  • Stay Lean: Only import the columns and rows you actually need. Every extra megabyte of data slows down your report and makes it harder to manage.
  • Automate with Folders: Use the "Folder" connector to handle recurring monthly or weekly files automatically, saving you hours of manual data combining.

By mastering these connection types and following best practices, you are ensuring that your Power BI reports are not just functional, but are built to scale with your organization's needs. Now that you understand how to get the data, you are ready to move into the Power Query Editor to start cleaning and shaping it for analysis.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.