KNOWLEDGE BASE

Converting a Connection to Custom SQL


Published: 12 Nov 2014
Last Modified Date: 29 Sep 2023

Question

How to convert a connection to a table or joined tables into a custom SQL query in Tableau Desktop

Environment

Tableau Desktop earlier than 2019.1. (See IMPORTANT note in Additional Information)

Answer

Option 1: When connecting to data sources that support SQL connections

  1. Connect to the data source.
  2. Drag at least one table into the canvas area.
    • Optional: Drag additional tables into the canvas area to create joins.
  3. Navigate to Data > Convert to Custom SQL

Option 2: When connecting to Excel

  1. Connect to Excel with the legacy data connector
    1. Connect to the file.
    2. In the Open dialog box, click the Open drop-down menu, and then select Open with Legacy Connection
  2. Drag at least one table into the canvas area.
    • Optional: Drag additional tables into the canvas area to create joins.
  3. Navigate to Data > Convert to Custom SQL

Additional Information

Note: The Convert to Custom SQL option may be grayed out or missing if the data source does not support a SQL connection, or if there is a cross-database join in the canvas area. For Excel and text file data sources, this option is available only in workbooks that were created before Tableau Desktop 8.2 or when using Tableau Desktop on Windows with the legacy connection.
 

IMPORTANT: Starting in Tableau 2019.1, you can no longer create a new Legacy Excel or Text connection. Existing workbooks created with these legacy connections will continue to work until 2019.2, when all support for legacy connections will be removed. See the Legacy Connection Alternatives document in Tableau Community for alternatives to using the legacy connection.

Connecting to a Custom SQL Query
 

Did this article resolve the issue?