1 of 1 people found this helpful
There is a PIVOT function in Microsoft SQL Server which allows you to achieve the same thing. Thus you could pre-process the data in the SQL.
Take a look at this sample - Simple Way To Use Pivot In SQL Query - CodeProject
thanks so much! However, I am afraid that my customer won't be too keen on changing the data in the database. Is there a way to do this in custom SQL?
The PIVOT function won't change any data, it's just part of a regular SELECT statement.
You're asking "Is there any way to do this in custom SQL?" the answer is - change your SQL to use the PIVOT function.
If what you're actually trying to ask is "Is there any way to use a Custom SQL source in Tableau and use the 'Pivot Data (from Columns to Rows) function unfortunately the answer is no - the only supported sources are Microsoft Excel and Text Files. You could execute your SQL outside of Tableau, save to Excel and connect to that instead. Pivot Data (from Columns to Rows)
This is a bit late, but I thought that I would just throw this out there.
You can "PIVOT" your data from SQL by using SQL's 'Union' function with Tableau's custom SQL.
See the query below (I've used your Excel data with the Legacy Connector, but it works with SQL as well):
...and here are your results: (I've added the FORMAT([Column],'#,###') to have the values look the same your example.)
Hope this helps.