How Well Does ChatGPT Know Tableau?
In case your rock is super comfortable, and you haven’t heard of ChatGPT, it is an AI chat bot that can respond amazingly well to human questions. It has been all over the internet recently with cases of folks testing the limits, predicting who it will put out of jobs and marveling at its ability to come up with complex answers. Well just how well versed is ChatGPT when it comes to Tableau? I decided to run it through a various slate of questions that I would expect people who have been working with Tableau to know to see just how well ChatGPT can do.
What additional value would we be looking to get out of ChatGPT? Well, the biggest driver would be providing additional context or lowering the time needed to find the information you are looking for. Much of anyone’s time who is trying to figure out something new is spent on searching for quality sources of information that can help the person understand the subject better. If ChatGPT can make consumption easier and more readily understandable that is a big win. The user must also be able to trust the information coming back from ChatGPT, especially if the current context is low, otherwise we can get a false sense of confidence in something that may seem right on the surface but is actually not what the user needs.
First let’s start off with some basics. I will be pasting my questions and the ChatGPT answers below.
Me: What is Tableau?
ChatGPT: Tableau is a data visualization and business intelligence software that allows users to easily create and share interactive charts, graphs, maps, and other data visualizations. It is designed to help users explore, analyze, and understand their data in a more intuitive and interactive way. With Tableau, users can connect to and import data from a wide variety of data sources, including spreadsheets, databases, and cloud-based data platforms. They can then use the software’s drag-and-drop interface to build visualizations and dashboards, and share their insights with others through interactive reports and dashboards. Tableau is widely used in a variety of industries, including finance, healthcare, and education, to help organizations make data-driven decisions.
Pretty good summary! Well written and captures most of the salient points. It doesn’t mention any of the products or features in detail so let’s follow up with a bit more detailed question.
Me: What products does Tableau offer?
ChatGPT: Tableau offers a range of products for data visualization and business intelligence. These products are designed to meet the needs of different types of users and organizations.
Here is a list of some of the products that Tableau offers:
Tableau Desktop: This is the primary product offered by Tableau and is a powerful data visualization and analysis tool that allows users to connect to, visualize, and analyze data from a wide variety of sources. It includes a range of features such as drag-and-drop visualization creation, mapping, and predictive analytics.
Tableau Server: This is a web-based version of Tableau Desktop that allows users to publish, share, and collaborate on data visualizations and dashboards. It is ideal for organizations that want to make their data available to a larger group of users.
Tableau Online: This is a cloud-based version of Tableau Server that allows users to access and interact with data visualizations and dashboards from any device with an internet connection.
Tableau Mobile: This is a mobile app that allows users to access and interact with their Tableau dashboards and reports on the go.
Tableau Data Management: This is a suite of products that helps organizations manage, govern, and secure their data. It includes products such as Tableau Catalog, Tableau Data Management Add-on, and Tableau Data Gateway.
Tableau Developer Tools: This is a set of tools and resources that developers can use to build custom integrations and extensions for Tableau. It includes the Tableau API, Tableau Extension Gallery, and Tableau Developer Community.
Not bad! It missed Tableau Prep and it calls Cloud Online, which is a fairly recent switch. If you look at some of the notes around ChatGPT it does say that it is not all the way up to date on recent information and stops somewhere in 2021 for references. I am impressed it even mentions the developer tools as a product.
Now let’s start getting into some more mechanical questions in the inner workings of Tableau. Let’s give it a good one and see if it can tell us what an LOD calculation is.
Me: What is an LOD calculation in Tableau?
ChatGPT: In Tableau, an LOD (Level of Detail) calculation is a type of calculated field that allows you to specify the level of granularity at which a calculation is performed. LOD calculations allow you to perform calculations on data at a different level of detail than the level of detail at which the data is displayed in a view.
There are three types of LOD calculations in Tableau:
FIXED LOD calculations: These calculations are performed at a fixed level of detail, regardless of the level of detail in the view.
INCLUDE LOD calculations: These calculations are performed at the level of detail in the view, plus an additional level of detail specified in the calculation.
EXCLUDE LOD calculations: These calculations are performed at the level of detail in the view, except for the level of detail specified in the calculation.
For example, suppose you have a dataset containing sales data by state and city. If you create a view that shows total sales by state, you could use an LOD calculation to show the average sales per city within each state. This would allow you to perform the calculation at the city level, even though the data is displayed at the state level in the view.
LOD calculations are a powerful feature of Tableau that can help you gain insights into your data that would not be possible with regular calculations. They are particularly useful for analyzing data at different levels of granularity and for comparing data across different levels of detail.
Nice! It tells us what they are used for, the three types, and an example of when we would want to use it. Impressive! What if we now are stuck and don’t know how to write one? Let’s see if it can give us back the example above.
Me: Write a tableau lod calculation that shows the average sales per city within each state.
ChatGPT: To create an LOD calculation in Tableau that shows the average sales per city within each state, you would need to follow these steps:
Connect to your data source in Tableau and drag the “State” and “City” dimensions and the “Sales” measure to the canvas.
Right-click on the “Sales” measure and select “Measure (avg)” to create an average of the sales measure.
Right-click on the “City” dimension and select “Create Calculated Field”.
In the Calculated Field dialog, enter a name for the calculated field, such as “Avg Sales per City”.
In the formula field, enter the following formula:
{ INCLUDE [City]: AVG([Sales]) }
This formula creates an INCLUDE LOD calculation that calculates the average sales per city, at the level of detail of the City dimension.
Click “OK” to create the calculated field.
Drag the “Avg Sales per City” calculated field to the Color shelf in the Marks card to show the average sales per city as a color encoding on the map.
Drag the “State” dimension to the Columns shelf and the “City” dimension to the Rows shelf to create a table view showing the average sales per city within each state.
This will create a Tableau view showing the average sales per city within each state. You can customize the view further by adding additional dimensions and measures, or by using other formatting options.
Step by step instructions! It picks the include LOD to tackle this problem and writes the formula assuming some names it thinks would be present in your data source. It starts all the way from the beginning and follows each step on the way through to the viz.
These look like pretty good instructions on the surface, but it is missing a few key elements. In the beginning instructions it gives a good step by step list to get to the LOD creation and can be done off the Superstore dataset. Once you get past the LOD creation it makes a few assumptions that don’t line up. It never tells you what aggregate method to use on top of the LOD, which is quite important and contextual to the viz, they will produce different outputs depending on what you pick. It also assumes you have a map visualization, which was never stated in the instructions. The last piece is that in setting up the final viz it includes all of the detail from the dimensions so that the output between the two measures is the same, not a great demonstration of the use case.
Next let’s ask it something more code heavy from the API side of the products. Can ChatGPT write something for us using the REST APIs?
Me: Write a program that downloads all users from Tableau Server
ChatGPT: To download all users from a Tableau Server, you will need to use the Tableau Server REST API. Here is an example of how you could do this using Python:
First, install the
tableauserverclient
library using pip:
pip install tableauserverclient
Next, import the necessary libraries and define the Tableau Server URL, username, and password:
from tableauserverclient import Server
server_url = "https://my-tableau-server.com"
username = "my-username"
password = "my-password"Use the
Server
class to connect to the Tableau Server and authenticate using the provided credentials:
server = Server(server_url)
server.auth.sign_in(username, password)
Use the
server.users.get()
method to retrieve a list of all users on the server:
users = server.users.get()
Iterate through the list of users and print out their names:
for user in users: print(user.name)
Don’t forget to sign out when you are finished:
server.auth.sign_out()
This is just a basic example, but you can use the
tableauserverclient
library to perform a variety of other operations on Tableau Server, such as creating and deleting users, setting permissions, and more. Please refer to the library's documentation for more information.
I am pretty impressed it managed to pick up the code from the TSC library and write context around it and that it picked up on my specific use case. It even covers some of the prerequisites such as installing the library using pip. From here is starts to take some interesting paths. First it imports only Server from the library, which is an interesting choice. If we only used methods from this module it would be a good way to manage import scope, however the library is so cross dependent it will limit us quickly. It then makes some shortcuts on the sign in authorization by not using the TableauAuth class. In the last part of printing out the users it tries to call an attribute from a list item that is returned so it won’t actually do that part.
This could be incredibly frustrating to try and troubleshoot if you have low context knowledge of what is going on, and you would likely need to reference the Tableau documentation to understand what is happening and how to fix it.
So is ChatGPT going to replace developers and make certain jobs obsolete? Well not any time soon in my mind. The primary value of ChatGPT with higher accuracy and stronger context is to make the knowledge attainment process easier for folks when they are learning new things. If it can create greater efficiency for an individual it could help up the amount of work that can be accomplished. Until then you will need the context provided by highly skilled developers to make sure that as levels of automation become higher someone is checking to make sure that it is solving the problem at hand in the correct way. Without context technology can be spectacularly wrong, or not even solve the correct problem in the first place.