Loading
Ongoing maintenance for Salesforce HelpRead More
Feature degradation | Gmail Email delivery failureRead More

Transposing/Pivoting Salesforce Data

Publish Date: Apr 30, 2025
Description
There is no option to pivot/transpose data from a Salesforce data source.

Cause

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 Salesforce.com 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.
Resolution
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".

Calculation:
====
CASE [Pivot Field Names]

WHEN "Column Name1" THEN [Column Name1]

WHEN "Column Name2" THEN [Column Name2]

WHEN "Column Name3" THEN [Column Name3]
...
END
====
 

Option 2

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

001472187

 
Loading
Salesforce Help | Article