Join our FREE personalized newsletter for news, trends, and insights that matter to everyone in America

Newsletter
New

Connecting Powerbi To A Postgresql Database

Card image cap

PowerBI is a business intelligence (BI) tool developed by Microsoft, designed to help users visualize data, create interactive dashboards and make informed decisions.
It is widely used across industries because it simplifies complex data and presents it in a visually compelling way.
PowerBI enables data analysts to :

  • Connect to multiple data sources
  • Transform and clean data
  • Do Data modelling
  • Build interactive dashboards and reports
  • Share insights across teams and organizations

One of the strengths of PowerBI is its ability to connect to multiple data sources, particularly SQL databases.

SQL (Structured Query Language) databases are the backbone of modern data storage systems.
SQL databases are very essential because they:

  • Store large volumes of structured data
  • Ensure data integrity and consistency
  • Allow efficient querying and data retrieval
  • Support complex analytical operations

By connecting PowerBI to SQL databases, companies can unlock real-time insights, improve data accuracy and streamline their analytics workflow.

In this article, we will walk through how to connect Power BI to both a local PostgreSQL database and a cloud-hosted PostgreSQL database (Aiven), and how to model your data effectively inside Power BI.

Connecting PowerBI to a local PostgreSQL database
Let us first see how to connect PowerBI to a local PostgreSQL database.

Step 1: Open Power BI Desktop Application
Launch Power BI Desktop on your computer if you have it installed. If not you can download it from the Microsoft store here PowerBI Desktop download link

Step 2: Click “Get Data”
On the Home ribbon, click Get Data to view all available data sources.

Step 3: Select PostgreSQL Database
Choose the database category, then select PostgreSQL Database


After selecting the PostgreSQL, press Connect.

Step 4: Enter Connection Details
After pressing Connect, you will be prompted to enter your postgreSQL connection details.

You will have to check your local postgreSQL connection to check on the connection details i.e; right click on your database then select Edit connection, it will bring you to this page;


From this page you are able to get the server name(host), database, port and other information.
Server: localhost:5432 (you put your server name:then port)
Database: your database name.

After putting your server name and database name, click OK.

Step 5: Provide Credentials
Then Enter your Username and password from your local postgreSQL connection.
It should look like this;


Then Click Connect.

Step 6: Load Data
After Clicking Connect, Power BI will display a Navigator window showing available tables on the left.


Select the tables you need by ticking their respective checkboxes.
For me I'm choosing the tables;

  • customers
  • products
  • sales
  • inventory

My selected tables have "assignment." before their names because they are in a schema called assignment.

After selecting your tables, you can choose to load
or Transform Data or Cancel depending on what you want to with the data first.
For my case I'm selecting Load.
After Selecting Load, the tables then get loaded to your PowerBI and you can be able to perform data cleaning, data validation, data modelling, data analysis and visualization.


You can navigate from the right side to select your tables and work on them.

Connecting PowerBI to a cloud database-Aiven PostgreSQL database
Cloud databases are increasingly popular today because they allow us to have remote access to our databases, ensure scalability and ensure high availability of our databases.
Aiven provides managed PostgreSQL services in the cloud.

Step 1: Go to Aiven and check for your PostgreSQL database connection if you have one. If you don't have one then create a new database connection.


If you have a connection, open it, if you don't have one then Create service from the top right corner.
Open your SQL connection from Aiven by double clicking it. Then go to Connection information.

From the Connection Information, check for:

  • Host (e.g., your-db.aivencloud.com)
  • Port
  • Database name
  • Username
  • Password

Step 2: Download SSL Certificate
Aiven enforces secure connections using SSL (Secure Sockets layer).
Download the CA Certificate (usually a .pem file) from your Aiven service dashboard.

After clicking the CA certificate download, it will be downloaded and you have to save it in a secure and accessible location on your computer.
SSL is Important because it ensures:

  • Data encryption during transmission
  • Protection against unauthorized access
  • Secure communication between Power BI and the cloud database. Without SSL, your data could be exposed to security risks.

Step 3: Install PostgreSQL ODBC Driver
To be able to connect PowerBI to an aiven PostgreSQL database, you need a PostgreSQL ODBC Driver.
You can download it using the link Download PostgreSQL ODBC Driver here
After installing in, open the ODBC Data Sources from your computer.

Step 4: Create an ODBC connection
After opening ODBC Data Sources
Go to System DSN then click Add
Select PostgreSQL Unicode(x64)

Click Finish then it will open up the window below.
Input your connection details from your Aiven PostgreSQL database as shown below;

Step 5: Configure SSL
Enable SSL mode by Setting SSL Mode to require
Provide the certificate file path if required

Click Test to see if your connection is Okay. If Connection is okay, proceed and save. If not recheck your connection details

Step 6: Launch PowerBI and Get data from your ODBC
After saving, close it the go and open your PowerBI desktop.
Go to Get Data and search for ODBC


Select ODBC and click Connect
Select your Data source Name and click okay

Then input your username and password from your Aiven connection then press Connect.
Step 6: Select your tables from the Navigator
A navigator window will open up. Then choose the schema where your tables are and then select your tables. For me my schema is assignment and my tables are Customers, inventory, products and sales.
Click Load to load your tables.

Loading tables in PowerBI and creating relationships
After loading the tables, PowerBI automatically detects the relationships between the tables based on shared columns.
However it is necessary to verify these relationships before working on the data to ensure accuracy.

For my case, I have four tables;

  • Customers table: stores customer information
  • Products table: contains products details
  • Sales table: records sales transactions
  • Inventory table: tracks stocks levels

To create relationship between tables in PowerBI;
Launch your PowerBI desktop if you haven’t.
Go to the Modelling tab in your PowerBI and select Manage Relationships.

Check the relationships if they are okay and select the relationship you want to edit if any then click edit.

Edit the relationship appropriately then Save.

Proper relationships in PowerBI are important because they allow analysts to:

  • Join tables correctly.
  • Aggregate data accurately.
  • Enable filtering across visuals.
  • Build meaningful dashboards.

Importance of SQL skills for PowerBI analysts
While PowerBI is a powerful visualization tool, SQL remains a critical skill for any data analysts.
SQL helps analysts to:

  • Retrieve data efficiently from databases
  • Filter datasets using conditions
  • Perform aggregations
  • Join multiple tables
  • Prepare clean datasets before importing into PowerBI

In real world scenarios, analysts rarely use raw data directly. Instead they Use SQL to extract and shape data, Load the data into PowerBI then they build dashboards and generate insights from the data.

Conclusion
PowerBI and SQL databases together form a powerful combination for data analysis and business intelligence.
SQL databases provide a reliable and structured way to store and manage data whereas PowerBI transforms that data into clear and interactive insights that support data driven decision making.
Being able to connect Power BI and SQL together gives analysts a competitive advantage and organizations that leverage on this integration make smarter, faster and more informed decisions, which translate to better outcomes and sustained growth.