Connecting to PostgreSQL Database in Power BI Desktop
Microsoft Power BI Desktop is a business intelligence tool which can be used to connect to any type data source I.e either a file or from a database, transform and visualize the data.
In Power BI Desktop, we can connect to data from many different sources. To connect to data, select Get Data from the Home. Select the down arrow, or the Get Data text on the button, it shows the most common data types and on clicking on more it will open a window with all the data types available in Power BI Desktop. See the below images:


- Here we will connect to postgresql database
- Select the postgresql database connector and click on Connect. Unfortunately we are getting the error as below image
- Click on Learn More and it will open the below link
- Install the latest version of the Npgsql and restart the machine. This will not resolve the error.
- To resolve this, we have an alternative solution to connect PostgreSQL database i.e. using “ODBC” generic database connector.
- Using the below link download the latest version of ODBC connection for PostgreSQL database and Install
- After installation completed, open the Power BI Desktop and choose Get Data
- Instead of selecting postgresql database, this time we will choose ODBC. Select ODBC and click on Connect
- A window will open and select “None” as Datasource Name (DSN)
- In the same window, we have connection string. Here we have to provide proper connection details to connect postgresql database. We won’t be able to click “OK” until we have provided the correct connection string. See the below image
- To get the proper connection string use this link.
- We have given the below connection string and able to click on “OK”
Connection String: Driver={PostgreSQL ANSI(x64)}; Server=localhost; Port=5433; Database=foodmart
- Then it will open a window to enter the credentials
- Enter the username and password and click on connect
- Now it will open a window with list of tables available in the selected database.
- Choose the table whatever you need and play with data.