Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs
  • MySQL

Connect Power BI to SQL Server

Let us see the step by step approach to connect Power BI to SQL Server Database. In addition to this Connect Power BI to SQL Server, how to use SQL Queries against the data present in SQL Tables with an example.

Step by Step approach to Connect Power BI to SQL Server

If you haven’t started the Power BI Desktop yet, Double click on the Power BI desktop to open. Once it is open, it looks like the below screenshot. Please click on the Get Data hyperlink

Connect Power BI to SQL Server 1

If you are in the Power BI visualization page, under the Home tab, click the Get Data option and select the SQL Server, as we showed below. Or select More options.

Connect Power BI to SQL Server 2

We are selecting More options to show you the following window. Use this window to select your desired Data source. Here, we are discussing hot to Connect Power BI to SQL Server. So, let me select the SQL Server Database Option.

Connect Power BI to SQL Server 3

Connect Power BI to SQL Server

The following are the list of available fields to fill to connect Power BI to SQL Server Database

  • Server: Please provide the SQL Server Instance name. If you installed SQL with default instance, then the instance name is the computer name or localhost.
  • Database: This is optional. If you want to use a custom SQL query then it is required.
  • Data Connectivity Mode: Please select whether you want to import or Direct query.
Connect Power BI to SQL Server 4

Clicking the Advanced option show you the advanced properties.

Connect Power BI to SQL Server 5

You can write your own SQL query to extract data from the specified Database. To do this, write your query inside the SQL Statement box

Connect Power BI to SQL Server 15

Custom Query that we used in the above Connect Power BI to SQL Server screenshot is:

-- Connecting Power BI to SQL Server
SELECT Geo.EnglishCountryRegionName AS Country, 
       Geo.StateProvinceName AS State, 
       SUM(Fact.SalesAmount) AS Sales, 
       SUM(Fact.TaxAmt) AS Tax, 
       COUNT(Fact.OrderQuantity) AS Orders
FROM FactResellerSales AS Fact
  INNER JOIN
     DimSalesTerritory ON 
        Fact.SalesTerritoryKey = DimSalesTerritory.SalesTerritoryKey 
  INNER JOIN
     DimGeography AS Geo ON 
        DimSalesTerritory.SalesTerritoryKey = Geo.SalesTerritoryKey
GROUP BY Geo.EnglishCountryRegionName, Geo.StateProvinceName
HAVING COUNT(Fact.OrderQuantity) > 60000

If you want to use this data, then click Load. For now, let me click the cancel button because I want to select multiple tables.

Connect Power BI to SQL Server 16

NOTE: Don’t worry above the Query, Just understand the procedure. However, If you want to learn, please refer to our SQL Server Tutorial

Let me use the local instance, and click OK

Connect Power BI to SQL Server 6

For now, we are using the current local windows credentials. If you don’t have the permission to access SQL Server, then use other person windows credential by selecting Use alternative credentials.

Connect Power BI to SQL Server 7

In real-time, we only use SQL Server Database credentials. For this, select the database and enter the username and password provided by the Admin person.

For now, I am using the current windows credentials

Connect Power BI to SQL Server 8

Under the Display options, it lists out the Databases that are available for that Instance. In this example, We are selecting the AdventureWorksDW2017 database.

You can download this database from Microsoft official Download Center or GitHub for free.

Connect Power BI to SQL Server 9

Expanding the Database folder display the available Tables and Views. Selecting the table shows the Data Preview.

Connect Power BI to SQL Server 10

From the below screenshot, you can see that we are selecting the required tables. Remember, if you are confused to select tables, then select one Measure table (Orders, or Sales) and click Select Related Tables button.

  • Load: This will load data from selected tables to Power BI. As I know that the data is clean, let me click the Load button
  • Edit: Click this button to alter the columns, or to cleanse the data
Connect Power BI to SQL Server 11

Please wait until the load is complete

Connect Power BI to SQL Server 12

Now you can see the Tables that we selected from the SQL Server database under the Fields section.

Connect Power BI to SQL Server 13

Expand any table to see the columns (fields) inside that table.

Connect Power BI to SQL Server 14

TIP: This is the Dataset that we are going to use in most of the Power BI tutorial.

Filed Under: Power BI

  • Install Power BI Desktop
  • Connect Power BI to SQL Server
  • Add Rename and Duplicate Pages
  • Connect to Multiple Excel Sheets
  • Get Excel Data to Power BI
  • Get Text File Data to Power BI
  • Load Data from Multiple Sources
  • Remove Power BI Table Columns
  • Create Power BI Bins
  • Power BI Joins
  • Change Column Data Types
  • Combine Multiple Tables
  • Power BI Clusters
  • How to Enter Data into Power BI
  • How to Format Dates in Power BI
  • Create Power BI Groups
  • Create Power BI Query Groups
  • Create Power BI Hierarchy
  • Power BI Pivot Table
  • Power BI Unpivot Table
  • Rename Power BI Table Names
  • Rename power bi column names
  • Split Columns in Power BI
  • Remove reorder power bi column
  • Power BI Area Chart
  • Format Power BI Area Chart
  • Power BI Bar Chart
  • Format Power BI Bar Chart
  • Power BI Clustered Bar Chart
  • Clustered Column Chart
  • Create a Power BI Card
  • Format Power BI Card
  • Create Power BI Multi-Row Card
  • Format Power BI Multi-Row Card
  • Power BI Column Chart
  • Format Power BI Column Chart
  • Power BI Donut Chart
  • Format Power BI Donut Chart
  • Power BI Funnel Chart
  • Format Power BI Funnel Chart
  • Power BI Heat Map
  • Power BI Line Chart
  • Format Power BI Line Chart
  • Line & Clustered Column Chart
  • Format Line & Clustered Column
  • Line & Stacked Column Chart
  • Format Line & Stacked Column
  • Power BI Matrix
  • Format Power BI Matrix
  • Power BI Table
  • Format Power BI Table
  • Add Data Bars to Power BI Table
  • Add alternate Table Row Colors
  • Power BI Pie Chart
  • Format Power BI Pie Chart
  • Power BI Ribbon Chart
  • Format Power BI Ribbon Chart
  • Power BI Treemap
  • Format Power BI TreeMap
  • Power BI Scatter Chart
  • Format Power BI Scatter Chart
  • Power BI Stacked Area Chart
  • Power BI Stacked Bar Chart
  • Format Stacked Bar Chart
  • Power BI Stacked Column Chart
  • Format Stacked Column Chart
  • Power BI Waterfall Chart
  • Format Power BI Waterfall Chart
  • Power BI 100% Stacked Bar Chart
  • 100% Stacked Column Chart
  • Create a Power BI Map
  • Format Power BI Map
  • Power BI Filled Map
  • Format Power BI Filled Map
  • Power BI Basic Filters
  • Power BI Slicer
  • Power BI Top 10 Filters
  • Power BI Drill through Filters
  • Power BI Filters on Measures
  • Power BI Advanced Filters
  • Power BI Report Level Filters
  • Power BI Page Level Filters
  • Power BI Calculated Columns
  • Add Conditional Column
  • Create Power BI Custom Column
  • Power BI Calculated Measures
  • Power BI Calculated Tables
  • Power BI DAX String Functions
  • Power BI DAX Math Functions
  • DAX Trigonometric Functions
  • Power BI DAX Date Functions
  • Power BI DAX Logical Functions
  • Power BI DAX Agg. Functions
  • Power BI Dashboard Introduction
  • Power BI Dashboard Settings
  • Power BI Dashboard Actions
  • Delete Power BI Dashboard
  • Subscribe Power BI Dashboard
  • Add Web Content to Dashboard
  • Add Image to Dashboard
  • Add video to power bi dashboard
  • Add Title to Power BI Dashboard
  • Pin Workbooks to Dashboard
  • Register to Power BI Service
  • Connect to Power BI Service
  • Create Power BI Workspace
  • Share Power BI Workspace
  • Create a Report in Workspace
  • Rename a Report in Workspace
  • Rename a Dataset in Workspace
  • Quick insights in Power BI
  • Get insights in Power BI
  • Publish power bi desktop report
  • Upload Power BI Workbooks
  • Upload Excel Files to Dashboard
  • Edit Power BI App
  • View Published Power BI App
  • Publish Power BI App
  • Share Power BI Dashboard
  • Share Power BI Workspace
  • Share Power BI Report
  • Power BI Q&A
  • Power BI Q&A Advanced
  • Customize Q&A Suggestions

Copyright © 2021ยท All Rights Reserved by Suresh.
About | Contact | Privacy Policy