Understanding custom SQL – when to use it and the pitfalls of using it
After we create our data models using relationships or joins, and analysts begin to interact with the data, Tableau dynamically creates SQL code to retrieve the data needed for the analyses. Tableau also goes beyond SQL with its proprietary query language called VizQL. VizQL adds additional features to SQL queries that also tells Tableau what chart type to use based on the data results from the query. Tableau does not expose the SQL and VizQL code it generates. It is all generated behind the scenes.
It is possible for us to write our own SQL in our data models using custom SQL. If we are connected to a data server that supports SQL queries, we will see a New Custom SQL option at the bottom of the tables from our database, as shown in Figure 9.20. Current versions of Tableau do not support custom SQL with Microsoft Excel:
Figure 9.20 – New Custom SQL option
After double...