DEV Community

Cover image for How to Connect PostgreSQL to Power BI using Local PostgreSQL.
Meghan Maina
Meghan Maina

Posted on

How to Connect PostgreSQL to Power BI using Local PostgreSQL.

Power BI is a business analytics and data visualization platform by Microsoft that is used to analyze data. It transforms raw data into interactive dashboards and visualizations that make data reporting easier.

It enables users to get data from a variety of sources using in-built data connectors. Once a connection is established, you can easily load your data into Power BI, then transform it as you would like with Power Query.

The most common place to store data is in databases. There are many types of databases including PostgreSQL, and Power BI provides a way to connect to each type. In this article, I will detail the steps to connect your locally hosted PostgreSQL database to Power BI.

Step 1: Open a new Power BI window and select 'Get Data'.

Once logged into your Power BI desktop application, open a new file and select Get Data to select your data source. On the drop down menu, select More... to see a variety of data sources.

Open Power BI

Step 2: Select database (PostgreSQL).

Once the menu is open, select the PostgreSQL Database connector and click Connect.

Select database type

Step 3: Configure the server name(localhost), port number, and database name.

When you click Connect, you will be required to enter the name of the server where the database is hosted. In this case, we are connecting to the localhost. I use the IP address for localhost in this case for simplicity.

Enter the port number as well, i.e. 127.0.0.1:5432, and the name of your database.

You may use Direct Query to establish a real-time connection with your database, or any of the advanced options. For this use case, select Import to import our data from the database.

Enter server name and port number

Step 4: Enter your credentials.

You are required to enter your username and password to sign into your database. Click Connect then wait for the connection to load.

Enter your database credentials

Step 5: Select schema/tables to load.

You are now ready to start the import process. To do this, select the schema or tables that you would like to import to Power BI. In this example I'm using the healthcare schema, which has various tables.

You may choose to load data then transform it, or load first then transform later. In this example, I chose Load.

Select tables to load

Step 6: Load tables.

The data has been successfully loaded onto Power BI. You can now transform and report on it.

Load data successfully

Next, we will discuss how to connect a PostgreSQL database hosted on a remote server to Power BI. It is just as simple and easy to do, with only a few minor adjustments. Until then, have fun trying this tutorial out!

Top comments (0)