Seamlessly Integrate Power BI with MongoDB Atlas: A Step-by-Step Guide
Table of contents
Introduction
In today’s data-driven world, making informed decisions swiftly is essential for businesses of all sizes. This is where Business Intelligence (BI) tools like Power BI come into play. Power BI empowers organizations to collect, analyze, and visualize data from different sources in real-time. As businesses increasingly rely on cloud-based infrastructure, the need for seamless integration between BI tools and databases like MongoDB Atlas has grown substantially.
Recently, I stumbled upon several posts online about people facing difficulties in connecting their Power BI Desktop to MongoDB Atlas. I encountered the same problem too, and after spending two days troubleshooting and looking for answers online, I managed to solve it.
This article offers a detailed walkthrough on how to link Power BI Desktop to MongoDB Atlas. By the end of this guide, you'll have a fully functional connection that enables real-time data analytics, helping you make the most of both tools' powerful capabilities.
A little Background
In Power BI, there are two methods of connecting to MongoDB. The first is with the ODBC (Open Database Connection), and the second is through the Power BI connector for MongoDB Atlas.
These two methods are part of the Atlas SQL connection option. Using the Atlas SQL interface, you can use SQL-style queries to search data on a federated database instance. This capability allows you to visualize, graph, and report on your Atlas data using relational BI tools such as Power BI and Tableau.
Atlas Data Federation is a distributed query engine that allows you to natively query, transform, and move data across various sources inside & outside of MongoDB Atlas. Details about how to set up a federated database are on the MongoDB Atlas website.
For a Power BI connection to be successful, your system must have the MongoDB Atlas ODBC DSN (Data Source Name) configured correctly.
Before we get started, you should:
Ensure you have an active MongoDB Atlas account. You can create one on the MongoDB Atlas website.
Make sure you have a cluster set up in MongoDB Atlas. If you don’t have a cluster yet, MongoDB provides easy-to-follow instructions for creating a free-tier cluster.
Create a user with the necessary privileges in the database access section in MongoDB Atlas.
Have the latest version of Power BI installed.
Now let's get the necessary drivers ready.
Download the following drivers from the MongoDB website.
a. MongoDB Power BI connector (Latest Version) - here
b. MongoDB ODBC driver (64/32 bits) - here
c. Atlas SQL ODBC
Next, we'll set up the drivers.
a. MongoDB Power BI connector.
Create a "custom connector" folder for Power BI (If it doesn't exist) in the following path:
C:\Users<user>\Documents\Power BI Desktop\Custom Connectors
.
Move the Power BI connector to this folder.
b. Install and configure the MongoDB ODBC driver (64-bit or 32-bit)
Doing this will add a MongoDB data source name (DSN) to your system data sources.
Note: You can install both drivers if you're unsure whether you use a 64-bit or 32-bit PC.
To configure the driver.
Search for ODBC in your start menu and open it.
Go to system DSN and click on add
Select the ANSI driver.
Enter a name for your data source
Enter a hostname (TCP/IP) - 127.0.0.1
Enter the port number - 3307
Add a username and password for the DSN and click okay.
c. Install and configure the Atlas SQL ODBC
Note: This driver is needed to connect Atlas SQL to external sources.
Enter the data source name you created in the previous step.
Add the username and password of the user you created in your atlas cluster.
Enter the connection string for MongoDB Atlas SQL. You can get it by clicking Connect on the cluster page and selecting the Atlas SQL option. This will create a federated database instance for you automatically.
Enter the database name.
You can test your connection to ensure it works.
Finally!!! Time to bring everything together
Open Power BI and select Get Data
Search for MongoDB and click Connect.
Enter your connection string and database name.
Enter your username and password then click OK.
Congratulations!!! You have successfully connected your Power BI to MongoDB. You can now ETL data from MongoDB into Power BI for real-time analytics and reporting.
Subscribe to my newsletter
Read articles from Boluwatife Oludupin directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Boluwatife Oludupin
Boluwatife Oludupin
Hi! Welcome to my blog. I am a Data Scientist who is addicted to solving real-world problems using data and this is where I pen my thoughts and share my knowledge. My journey into the amazing world of data started roughly 10 years ago as a mathematics undergrad where I developed a keen interest in data collection, operation research, python programming, and data analysis. I also worked on some personal porjects and data analysis gigs too. In 2019, I decided to dedicate my career to helping businesses make sense of their data for decision-making and driving growth. This decision spurred me into a lifelong journey of learning and personal development. I am also very keen on mentoring individuals who want to take up a career in data.