Wrangling Joined Salesforce Reports with Pivot Tables

ExcelCT

New Member
Joined
Feb 13, 2020
Messages
10
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
  2. MacOS
  3. Web
Hello all.

If anyone has used joined reports in Salesforce, you'll know the export output is limited to grouped, pre-formatted Excel sheets that are not (in Salesforce parlance) 'detailed reports'. For using pivot tables with these exports, this is a bit of a problem because there are not repeating rows and rather the data looks like below. The actual report is way more complicated, but I've made a sample of how the data looks. If with your help I can figure out how to get a working pivot table with this sample data, I'm confident I could handle the rest of the work.

About the data: This is the format it comes out of Salesforce. I can image some ways I could get my required output (see below) without using pivot tables - but I love pivot tables and would like to use them if possible. I know I could do some amount of "post processing" via macros or helper columns - and I may have to do that. I would like to keep post-processing to a minimum.



It's important to note that the strategy entries (or lack thereof) and the goals (or lack thereof) are independent of each other. That is the 'join' in Salesforce (in my example, the join is on Company). Thus each company can have 0 to n number of Strategies and 0 to n number of Goals. They have both. They may have neither. Obviously pivot table out of the box can't really deal with this format very well. As humans, it is easy to understand what I'm trying to get to, but not sure how to make a pivot table do this. I do have PowerPivot and have used it somewhat in the past but not an expert user of it. But if there is a PowerPivot-based solution, I could enact that.

Thanks in advance for your help.

-CT

Screen Shot 2020-02-13 at 11.04.26 AM.png

Screen Shot 2020-02-13 at 11.04.09 AM.png
 

Attachments

  • Screen Shot 2020-02-13 at 10.44.18 AM.png
    Screen Shot 2020-02-13 at 10.44.18 AM.png
    79.8 KB · Views: 4

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hello all.

If anyone has used joined reports in Salesforce, you'll know the export output is limited to grouped, pre-formatted Excel sheets that are not (in Salesforce parlance) 'detailed reports'. For using pivot tables with these exports, this is a bit of a problem because there are not repeating rows and rather the data looks like below. The actual report is way more complicated, but I've made a sample of how the data looks. If with your help I can figure out how to get a working pivot table with this sample data, I'm confident I could handle the rest of the work.

About the data: This is the format it comes out of Salesforce. I can image some ways I could get my required output (see below) without using pivot tables - but I love pivot tables and would like to use them if possible. I know I could do some amount of "post processing" via macros or helper columns - and I may have to do that. I would like to keep post-processing to a minimum.



It's important to note that the strategy entries (or lack thereof) and the goals (or lack thereof) are independent of each other. That is the 'join' in Salesforce (in my example, the join is on Company). Thus each company can have 0 to n number of Strategies and 0 to n number of Goals. They have both. They may have neither. Obviously pivot table out of the box can't really deal with this format very well. As humans, it is easy to understand what I'm trying to get to, but not sure how to make a pivot table do this. I do have PowerPivot and have used it somewhat in the past but not an expert user of it. But if there is a PowerPivot-based solution, I could enact that.

Thanks in advance for your help.

-CT

View attachment 6615
View attachment 6616

Sorry the 'What I would like' had a (hand typed) typo in it for Microsoft counts. Here is the corrected version

Screen Shot 2020-02-13 at 11.16.49 AM.png
 
Upvote 0
with Power Query (Get&Transform)
CompanyStrategyGoalCompanyGoalStrategy
IBMInvent PCApple03
Deep BlueFacebook31
Oxygen BatteriesIBM40
Kinetic EnergyMicrosoft33
MicrosoftSoftwareMS-DOS
HardwareZune
ServicesAzure
FacebookSoftwareFacebook.com
Instagram
WhatsApp
AppleSoftware
Hardware
Services

Code:
// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    FillD = Table.FillDown(Source,{"Company"}),
    Unpivot = Table.UnpivotOtherColumns(FillD, {"Company"}, "Attribute", "Value"),
    Pivot = Table.Pivot(Unpivot, List.Distinct(Unpivot[Attribute]), "Attribute", "Value", List.Count)
in
    Pivot
 
Upvote 0
with Power Query (Get&Transform)
CompanyStrategyGoalCompanyGoalStrategy
IBMInvent PCApple03
Deep BlueFacebook31
Oxygen BatteriesIBM40
Kinetic EnergyMicrosoft33
MicrosoftSoftwareMS-DOS
HardwareZune
ServicesAzure
FacebookSoftwareFacebook.com
Instagram
WhatsApp
AppleSoftware
Hardware
Services

Code:
// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    FillD = Table.FillDown(Source,{"Company"}),
    Unpivot = Table.UnpivotOtherColumns(FillD, {"Company"}, "Attribute", "Value"),
    Pivot = Table.Pivot(Unpivot, List.Distinct(Unpivot[Attribute]), "Attribute", "Value", List.Count)
in
    Pivot

That looks awesome! I am not sure if I have "Power Query/Get & Transform". For add-ons, I have Analysis ToolPak, Inquire, Power Map, Power Pivot, Power View, Solver, and Actions Pane 3. I work at a company that keeps all the PCs pretty "locked down" - so if don't already have it installed, I may or may not be able to get it installed :(. But will look into that. Thanks!
 
Upvote 0
2016 & 365 has Power Query and Power Pivot built-in
2013 need Power Query add-in

Thanks! I just figured that out myself after some Googling.

Never used this before but I'll work to figure it out. Thanks so much for the script!
 
Upvote 0
refresh thread and see post#5 again

Thanks. I'll try to unpack and understand what's going on. My real sheet is more complicated but if I can reverse engineer what's happening in your script, I should be able to get it to work for my real-life worksheet.

Thanks again.
 
Upvote 0
Upvote 0
1. select your range (first picture)
2a. Ctrl+T (it will create an Excel Table, check the name of this table in Name Manager, should be the same as in the M-code)
or
2b. use Data - From Table - it will open Power Query Editor

more about PowerQuery aka Get&Transform


I had tried to create a named range called Table1 but that didn't work. Your method worked fine, however.

Thank you SO much. Looks like it is working now.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top