BLOGAnnounced at MongoDB.local NYC 2024: A recap of all announcements and updates — Learn more >

How to Connect Tableau with MongoDB

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 thanks to MongoDB's Tableau Connector! Our Tableau Connector gives you the power to access and analyze live Atlas data from your Tableau desktop through a brand new Atlas SQL Interface that lets you leverage your Tableau skills and SQL knowledge. A direct connection to Atlas means you can find insights on application data in real time. And, with built-in workload isolation, long-running, complex analytical queries won’t disrupt application performance! In this tutorial, you’ll learn how to install and deploy the necessary tools you need to connect your Tableau dashboard to Atlas, allowing you to minimize complex ETL and find insights across multiple data sources to help your business.


Table of contents

Prerequisites

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. The Federated database needs to be sourced from MongoDB cluster(s) that are version 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.

Methods in connecting Tableau to MongoDB

The best way to connect Tableau to MongoDB is through the Atlas SQL Interface, using our custom Tableau Connector and JDBC driver. In this page, we are going to explore the Advanced Configuration pathway, which gives you the ability to create your own federated database instance in order to query from multiple sources at once.

Note: you can also connect to Tableau through the Quick Start pathway, which allows you to run Atlas SQL queries on data in the Atlas cluster that you specify by automatically creating a simple federated database instance in the background. You cannot modify this federated database instance, but you can delete it.

Connect Tableau to MongoDB with the Atlas Tableau Connector

To make use of the Tableau Connector in Atlas, you'll need to download a couple files in order for Tableau Desktop to recognize and make the connector available.

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:

  • Windows: C:\Program Files\Tableau\Drivers
  • macOS: ~/Library/Tableau/Drivers

The directory should exist, but if it doesn't, go ahead and create it.

Next, download the Custom Tableau Connector, also known as a TACO file. You'll want to move this file to one of two places depending on your operating system:

  • Windows: C:\Program Files\Tableau\Connectors
  • macOS: ~/Library/Tableau/Connectors

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.

Red highlight around a button which displays connecting using Atlas SQL.

Connecting to Tableau using the Atlas SQL Interface


Select ‘Tableau Connector” in the driver dropdown menu, and take note of the “URI” that you will need to plug in later. 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.

Red highlight around a text field which indicates the input necessary to connect to Tableau via the Atlas SQL Interface.

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.


Tableau input page for entering necessary information to connect to database.

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.


Default Tableau dashboard without any visualizations

Tableau dashboard after connecting via Atlas SQL Interface

Create a data pipeline

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:

  • Provide a count on the total customers and transactions.
  • Sum up the transaction count.
  • Count the number of accounts.

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 insights on customers, transactions, and a total sum of transactions.

Tableau worksheet with data visualizations

Exporting MongoDB data as JSON (Alternative Approach)

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

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

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

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

Tableau table with information about students and grades

Conclusion

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!

FAQ

Does Tableau work with MongoDB?

Yes, you can use MongoDB as a data source for SQL-based analytics and data visualization tools like Tableau.

Is MongoDB good for analytics?

MongoDB offers several powerful analytics benefits, namely because of the flexible schema requirements as a document-based database model.

What is MongoDB best used for?

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.

What is MongoDB Enterprise?

MongoDB Enterprise includes additional operational and management features, and a commercial license (warranty and indemnification), as well as access to proactive support and on-demand training.

Can Tableau connect to MongoDB?

Yes, Tableau can connect to MongoDB Atlas using the Custom Tableau Connector to access and visualize data.