Transposing/Pivoting Salesforce Data

Published: 20 Dec 2019
Last Modified Date: 27 Jan 2022


There is no option to pivot/transpose data from a Salesforce data source.


Tableau Desktop


There are 2 possible workarounds:

Option 1

Using a pivot calculation as follows:

1. Create a file with a list of all the column name you want to pivot.
2. Cross database join the file to Salesforce data using relation "1 = 1".
3. Rename the filed from file as "Pivot Field Names".
4. Create the following calculation fields:
Field Name: "Pivot Field Values".

CASE [Pivot Field Names]

WHEN "Column Name1" THEN [Column Name1]

WHEN "Column Name2" THEN [Column Name2]

WHEN "Column Name3" THEN [Column Name3]

Option 2

The closest workaround available would be to perform all desired aggregations/edits on the Salesforce data before bringing any data into Tableau. 


Per our documentation here: Pivot Data from Columns to Rows,
"Sometimes, analyzing data that is stored in a crosstab format can be difficult in Tableau. When working with Microsoft Excel, text file, Google Sheets, and .pdf data sources, you can use the "Pivot your data from crosstab" format into columnar format. If you are working with other data sources, you can Pivot using custom SQL (Tableau Desktop)."

The problem is that falls into "other data sources" and thus requires use of Custom SQL. And the problem with that is that custom SQL for Salesforce data (SOQL query) does not support alias for column names.
Did this article resolve the issue?