Did you know you can create/use temp tables within Tableau? It’s one of those features that hasn’t always existed, is very useful, and most people do not realize exists. Utilizing SQL Server as an example – you can make use of Initial SQL.

From here you can type out your SQL to generate temp tables.

Then, in your custom SQL you can reference that temp table. (I realize

This can then be published on the Tableau server and works as normal. The temp table will drop when the user session ends. This is very beneficial for smaller datasets that are performant in which you don’t want to go through the pain of creating a stored procedure. However – the downside is that the Initial SQL code can be hidden from anyone else trying to develop on the dashboard. Any yes – you can in fact utilize variables as you would in stored procedures within Initial SQL, good article here on how to do that.

Initial SQL has some other uses as well detailed by Tableau on their site here.