Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy,
including cookie policy.

She is wondering “Hmm, how do I export SQL?”

7 Steps To Export SQL


Statements From Tableau
Thomas Spicer Follow
Mar 13, 2017 · 5 min read

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 1/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

Sometimes you just


To make Medium want
work, we logthe
user SQL used
data. By using under
Medium, the hood
you agree in Privacy
to our Tableau!Policy,Maybe
including cookie policy.
you want to use the SQL with SQL Workbench or a different query or
business intelligence tool. However, Tableau does not make it easy to see
what is happening under the hood.

We have launched a code-free, zero-admin, fully automated data


pipeline for Tableau to leading cloud warehouses and data lakes.

Get started with Amazon Redshift, Google BigQuery, Redshift


Spectrum or Amazon Athena for free!

Exporting SQL From Your Workbook


Let’s say you have created a data visualization in Tableau like the simple
example below.

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 2/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy,
including cookie policy.

Simple data viz in Tableau

You would like to be able to run the SQL statement used to generate this
visualization in a different query tool. Seems like that should be simple
enough, right? Well, it turns out to be a little more complicated than you
would think.

Let’s Get Started: Step-By-Step Guide


We created this step-by-step guide to save you time and finally get a peek
under the Tableau covers. Note: This guide covers Tableau v9.x, there might be
slight variations for new versions. You may want to check these steps too!

Step 1: Pick Your Visualization


Once you have the desired visualization created in Tableau, the first step is
to select Help → Settings and Performance → Start Performance
Recording from the Tableau toolbar.

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 3/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy,
including cookie policy.

Select Performance Recording

Step 2: Refresh Your Data


Then right click on the source in the Data toolbar and select ‘Refresh’. This
will force Tableau to re-run the query.

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 4/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy,
including cookie policy.

Select Refresh to re-run the query

Step 3: Stop Performance Recording


Once the query completes, select Help → Settings and Performance → Stop
Performance Recording from the Tableau toolbar.

Stop Performance Recording

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 5/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

This should resultwork,


To make Medium in awenew Tableau
log user window
data. By using opening
Medium, with
you agree to a workbook
our Privacy Policy,
calledincluding
‘Tableaucookie policy.
— PerformanceRecording’

Performance Recording Summary

Step 4: View Your Data


Right-click anywhere in the bar next to ‘Executing Query’ and select ‘View
data’

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 6/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy,
including cookie policy.

Select ‘View data…’

Step 5: Grab The SQL Query


If you click the ‘Underlying’ (Tableau v9.x) or ‘Full Data’ (Tableau v10.x)
tab in the resulting pop-up window, you will see the SQL for the query in
the ‘Command’ field.

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 7/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy,
including cookie policy.

Query View

You can select statement by highlighting the text in that field, select ‘Copy’
and either paste it directly into the SQL tool of your choice or into a text file
for the time being.

Copy query

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 8/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

In ourToexample,
make MediumTableau SQL
work, we log statement
user data. looks like
By using Medium, this…
you agree to our Privacy Policy,
including cookie policy.

SELECT (((CAST(EXTRACT(YEAR FROM CAST(“sz_ad_report”.”delivery_date”


AS TIMESTAMP WITHOUT TIME ZONE)) AS INTEGER) * 10000) +
(CAST(EXTRACT(MONTH FROM CAST(“sz_ad_report”.”delivery_date” AS
TIMESTAMP WITHOUT TIME ZONE)) AS INTEGER) * 100)) + CAST(EXTRACT(DAY
FROM CAST(“sz_ad_report”.”delivery_date” AS TIMESTAMP WITHOUT TIME
ZONE)) AS INTEGER)) AS “md_delivery_date_ok”,

SUM(“sz_ad_report”.”impressions”) AS “sum_impressions_ok”

FROM “public”.”sz_ad_report” “sz_ad_report”

WHERE ((“sz_ad_report”.”delivery_date” >= (TIMESTAMP ‘2017–01–26


00:00:00.000’)) AND (“sz_ad_report”.”delivery_date” < (TIMESTAMP
‘2017–02–25 00:00:00.000’)))

GROUP BY 1

Step 6: Test Your SQL Query


You can then connect to a SQL tool like SQL Workbench using the same
connection details you used in Tableau, paste the SQL statement into the
‘Statement’ tab and click the ‘Execute’ button.

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 9/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy,
including cookie policy.

Test query

Step 7: Celebrate!
Voila! You should now see all the data used for the Tableau visualization in
the ‘Results’ tab.

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 10/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy,
including cookie policy. Query results

Now you can use this statement in other query tools without the need to
worry about how to write SQL in Tableau from scratch, and save time!

We have launched a code-free, zero-admin, fully automated data


pipeline for Tableau to leading cloud warehouses and data lakes.

Get started with Amazon Redshift, Google BigQuery, Redshift


Spectrum or Amazon Athena for free!

Want to discuss how to optimize Tableau for your organization?


Need a platform and team of experts to kickstart your data and
analytic efforts? We can help! Getting traction adopting new
technologies, especially if it means your team is working in different and
unfamiliar ways, can be a roadblock for success. This is especially true in a
self-service only world. If you want to discuss a proof-of-concept, pilot,

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 11/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

project or any
To make other
Medium work,effort, thedata.
we log user Openbridge platform
By using Medium, you agreeand
to ourteam
Privacyof data
Policy,
including cookie policy.
experts are ready to help.

Reach out to us at hello@openbridge.com. Prefer to talk to someone? Set


up a call with our team of data experts.

Visit us at www.openbridge.com to learn how we are helping other


companies with their data efforts.

Sign up for All Things Data - The Openbridge Newsletter


By Openbridge

We cover ELT, ETL, data ingestion, analytics, data lakes, and warehouses Take a look

Your email Get this newsletter

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information
about our privacy practices.

Sql Tableau Analytics Data Science Technology

Learn more. Make Medium yours. Share your thinking.


Medium is an open platform where 170 million readers Follow the writers, publications, and topics that matter to If you have a story to tell, knowledge to share, or a
come to find insightful and dynamic thinking. Here, you, and you’ll see them on your homepage and in your perspective to offer — welcome home. It’s easy and free
expert and undiscovered voices alike dive into the heart inbox. Explore to post your thinking on any topic. Write on Medium

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 12/13
12/12/2020 7 Steps To Export SQL Statements From Tableau | by Thomas Spicer | Openbridge

of any topic and bring new ideas to the surface. Learn


To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy,
more
including cookie policy.

About Help Legal

https://blog.openbridge.com/7-steps-to-export-sql-statements-from-tableau-7e51a2fd4277 13/13

You might also like