If you’re working to discover patterns, visualize information, and perform analysis on data, there’s no better solution than using MongoDB in conjunction with Tableau. Fortunately, connecting MongoDB Atlas to Tableau has never been easier, using the Tableau Named Connector, seamlessly allowing you to create Tableau visualizations and dashboards to extract insights in your multi-structured data. In this tutorial, you’ll learn how to install the necessary tools, find your federated database connection information, and connect to your federated database instance using Tableau.
Table of contents
To be successful with connecting Tableau to MongoDB, you'll have to meet a few requirements:
To use Tableau with MongoDB, you'll need a federated database instance within MongoDB Atlas. Federated database instances are only available with MongoDB Atlas 5.0 or greater. You can try MongoDB Atlas for free by creating an M0 cluster.
Throughout this article, you’ll see the “sample_analytics” dataset referenced. This dataset can be installed from within the MongoDB Atlas dashboard, but it isn’t a requirement to be successful. More information on the dataset can be found in the documentation.
There are several ways to easily connect Tableau to MongoDB which include the Tableau Named Connector and the Atlas SQL JDBC driver.
To make use of the Tableau Named Connector, you'll need a few extra files to get Tableau recognizing the connection option.
First, download the MongoDB JDBC Driver and make sure to choose the *.all.jar version from the list. You'll need to move this downloaded file to one of two places depending on your operating system:
The directory should exist, but if it doesn't, go ahead and create it.
Next, download the Tableau Named Connector, also known as a TACO file. You'll want to move this file to one of two places depending on your operating system:
Once again, if the directory doesn't exist, go ahead and create it.
You should already have a federated database instance within MongoDB as per the requirements of this tutorial. We need to obtain the connection information for that instance to be used in Tableau.
Within MongoDB Atlas, click the "Data Federation" tab. For the instance you'd like to connect to, click the "Connect" button followed by "Connect using the Atlas SQL Interface" button.
Connecting to Tableau using the Atlas SQL Interface
Take note of the "URI" in the "Tableau Connector" tab, but not the "Database" field. The database that you want to use as part of your connection is within "Configuration" section of your particular federated instance.
Selecting the URI to connect via the Tableau connector
Open Tableau Desktop or Tableau Server and navigate to the "Connect" menu. Choose "MongoDB Atlas by MongoDB" as your MongoDB Tableau connector option.
When prompted, enter the URI, database, username, and password information associated with the federated database instance within MongoDB Atlas.
Entering the necessary credentials to access the database via Tableau
If the connection was successful, you should see your database and collections that exist as part of your federated database instance within Tableau.
Tableau dashboard after connecting via Atlas SQL Interface
Perhaps we’d like to export our MongoDB data in order to analyze and make insightful decisions. In that case, use Tableau’s JSON connector to understand the data without any data preparation. This can be done using mongoexport, a CLI-tool that produces a JSON or CSV export of data stored in a MongoDB instance.
To easily use mongoexport
and generate a JSON file, we can use the “Command Line Tools” tab of our “Database Deployments” page.
Navigating to the Command Line Tools page
On the “Data Import and Export Tools” section, we can find a template command to produce an export of data stored in a MongoDB instance that we can then analyze using Tableau.
Template commands for mongoimport and mongoexport
For example, if we wanted to export the transactions
collection in our sample_analytics
MongoDB database to a file called export.json
mongoexport --uri mongodb+srv://username:password@database.dmhrr.mongodb.net/sample_analytics --collection transactions --out export.json
Now, with our exported JSON file ready, we can open Tableau’s JSON connector and select our file. Once opened, you can specify the required schema levels to include for analysis.
Tableau prompt for selecting schema levels moving forward after json import
Now, you’ll have an output from Tableau that we can begin to start analyzing and creating visualizations from to make better data-driven decisions.
Tableau table with information about students and grades
After Tableau has been connected to our Atlas cluster, we are able to see all of our collections from the federated database, and start working with our data to create visualizations. Let’s begin in the “Data Source” homepage of Tableau.
For example, in the sample_analytics
database, we’ve got various collections including customers
and transactions
. We can drag and drop these collections and link them together like so.
As we have created relationships between the customers
to transactions
as well as Accounts1
, we can now go to our worksheet Sheet1
to start creating tables to view our data. In our instance, we can use the Measure Names
calculation in the columns field, and the Measure Values
calculation in the rows, which will:
Now, you can create a horizontal bar chart displaying this data, and even use Tableau online to host this data for sharing and presentation purposes.
Tableau worksheet with data visualizations
You just saw how to connect Tableau to MongoDB in order to turn raw data into an understandable format. This can help to seamlessly create the Tableau visualizations and dashboards that will help you extract the insights and hidden value in your multi-structured data.
Want to learn more about what you can do with MongoDB Atlas? Find out here.
Got a question about the MongoDB Tableau connector? Swing by the MongoDB Community Forums!
Yes, you can use MongoDB as a data source for SQL-based analytics and data visualization tools like Tableau.
The best use cases for MongoDB include situations with unstructured data, including e-commerce, content management, game development, and many more uses where document orientation and high performance are key. For more details, check out the dedicated use cases page.
mongosqld
is the BI Connector program which connects your MongoDB instance to your BI tool. To start mongosqld
from the command line, run the mongosqld
executable in the BI Connector program directory with any necessary command line options.