top of page
Writer's pictureJennifer Dawes

TABLEAU ONLINE - METADATA EXERCISE #2

Updated: Aug 19

You saw the title but then you got nervous... Don't go anywhere we're doing this together!

Metadata and GraphiQL Recap

If you read, Tableau Online - Metadata Exercise #1 then the next few paragraphs are all a recap. You can either review or skip down to the query and run Metadata Exercise #2. If you are just getting started in metadata, the next few paragraphs will guide you through.


If you are thinking, what is Metadata and where do I begin? I have just the video for you to watch. Back in 2021, Anya Prosvetova introduced us during HER DATA LEARNS: METADATA API. This not only inspired me but helped me solve a practical issue for my organization at the time. It has taken me some time but I finally have a Sandbox Tableau Online account, Query, and Dashboard Template to share as we walk through this first query together.


Before I jump in let's talk a bit about the Sandbox Tableau Online account I am using. This was all possible to create thanks to the Tableau Developer Program. I was able to create a free Tableau Online account for the purpose of learning. Do you want to know more? Check out the link to join the program for free and get started.


Now, let's talk about GraphiQL. What is GraphiQL? "A query language for your API


GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools."


To jump to GraphiQL and query against your Tableau Online account you would replace everything after the # in your Tableau Online URL with metadata/graphiql/(see the example below).



You should see the window below if you used the correct URL.


If you made it this far, WOW! You already have accessed the GraphiQL and you are one step closer to querying against Tableau Online.


METADATA EXERCISE #2: Custom SQL


Have you ever wondered what Custom SQL dashboards are connected to? Maybe you inherited ownership of several workbooks and you want to better understand the data under the hood. This first exercise is going to get you all the goods on any Custom SQL data connections.


The Query:


The first exercise in Metadata that we will run is the query below. Copy and paste this script into GraphiQL and hit the play button.


query usersAndContent {
  customSQLTables {
    name
    id
    upstreamDatabases {
    name
    __typename
    connectionType
        }
    downstreamSheets {
      luid
      name
    }
    downstreamOwners {
      luid
      name
      email
    }
    downstreamDashboards {
      luid
      name
          }
    downstreamWorkbooks {
      luid
      name
      projectName
         }
      query
  }
}

If it ran correctly you should see the window below appear. If so, well done. You just ran a Metadata API query against Tableau Online. Now, we can jump to the exciting and sweet stuff.



Converting to a JSON:


These last few steps are simple. We right-click, select all and paste it into Notepad or Notepad++. Ultimately we want to save this file as a JSON but can't automatically from GraphiQL. I prefer the Notepad++ option myself. Once you save the file as a JSON you should notice the text colors change. Saving as a JSON supports the node structure which will be important when we pull this into Tableau to create the dashboard.


Selecting Schema Levels in Tableau:


Here is why it is important. When you pull the JSON file into Tableau, the first window you will see is 'Select Schema Levels'. I always check the top box to include all Schema Levels.

Once you select ok, you are connected to the JSON file and just successfully pulled Metadata and connected it to Tableau Desktop. From there run wild with creating a dashboard and insights you might need.


Tableau Workbook Template:


To save you some of the work I created a Tableau template for you to use, CUSTOM SQL Connections available on Tableau Public for download. Just download the workbook, replace my data source with your own JSON file, and you are ready to go.


That's a wrap:


If you have been able to follow the steps and completed Exercise #1 and #2 you are well on your way!


Let's talk about the practical uses of this dashboard. The purpose of this dashboard is to illustrate where Custom SQL is used and what query is used within published workbooks to Tableau. In short, this is useful to have a catalog of what dashboards or workbooks on Tableau Online are connected to Custom SQL queries. For documenting dashboards, this gets a step closer.


Intrigued? Keep digging into metadata to see all what's available.

340 views

Comments


bottom of page