'Pivot' your SQL data by using SQL's 'Union' Function within Tableau's Custom SQL

Version 1

    Just thought that I'd throw this one out there...


    I'm sure a lot of people have realized that you can only Pivot data from Excel or Flat files, but not from SQL.


    You can 'PIVOT' your data from SQL by using SQL's 'UNION' function with Tableau's custom SQL.


    So, this is how your data looks coming from SQL and you want to Pivot columns A & B...




    See the query below (I've used 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 clean up the values.)




    Hope this helps.