Ratio of Fields from Different Sheets in Excel Pivot

Click For Summary

Discussion Overview

The discussion revolves around computing the ratio of two fields, A and B, from different sheets within the same Excel workbook using Pivot Tables or other Excel functionalities. Participants explore various methods and challenges associated with this task, including the need for matching instances across tables.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant seeks advice on computing the ratio A/B from two fields located in different sheets, expressing difficulty in using the Excel Wizard.
  • Another participant requests clarification on the initial query, suggesting they might find a clean solution while acknowledging existing hacks.
  • A participant explains the need to compute the ratio for the same instance across both tables, indicating a requirement for a join operation to ensure A_i/B_i is calculated rather than A_i/B_j.
  • Concerns are raised about the limitations of using Excel for this task, with a suggestion that programming tools like pandas or numpy would be more suitable for such operations.
  • A proposed method involves creating a formula that references the two pivot tables without clicking on the pivot cells to avoid incorrect references, and using VLOOKUPs to retrieve values before performing the division.
  • Another participant reiterates the challenges of explaining Excel operations through text and expresses discomfort with the limitations of spreadsheets for complex tasks, suggesting a video tutorial might be more effective.
  • Additional complexity is introduced by the fact that field B is an aggregate, complicating the SQL query process due to the need for groupings.

Areas of Agreement / Disagreement

Participants express various challenges and propose different methods, but there is no consensus on a single effective solution. The discussion remains unresolved with multiple competing views on how to approach the problem.

Contextual Notes

Participants note limitations in Excel's ability to handle the required operations effectively, particularly regarding the need for matching instances and the complexity introduced by aggregate functions.

WWGD
Science Advisor
Homework Helper
Messages
7,804
Reaction score
13,108
Hi All,
I want to compute the ratio of two fields A,B from different sheets ( same workbook)
, using Pivot ( tho "straight" Excel will do*). I tried using the Wizard, but , in the end, could
not find a way of doing it:

upload_2018-1-23_20-52-41.png


Any ideas, please?
*I scewed big when trying this.
 

Attachments

  • upload_2018-1-23_20-52-41.png
    upload_2018-1-23_20-52-41.png
    66.2 KB · Views: 876
Computer science news on Phys.org
Can you explain a bit more? I could possibly find a clean way to do this, though I already have a few hacks in mind.
 
Thanks. I have two fields A,B given, both in the same workbook, although in different sheets, and I need to compute the field C:=A/B within Excel. It is a bit more problematic in that I do need to find the values of A,B for the same instance, say ##i## in both tables, so that I need something like a join, to make sure I compute ##A_i/B_i## instead of ##A_i/B_j ; j \neq i ##. Because of complicated reasons, I cannot do it within SQL. I tried to use Microsoft Query, but the connection was poor ( strangely so, given I could export data to/from SQL Server from Excel, and , of course, SQL server was running.); so I cannot " pullback" query results from Microsoft Query back to Excel.
 
I think this is going to be hard to explain over text as excel cells aren't quite standardized enough... (if you were using pandas or numpy in python things are almost taylor made for forum correspondence-- it really would be as simple as dropping in a couple lines of code... )

Does the below sketch work?
- - - -
you have two pivot tables. Linking to pivots is the same as as with regular cells excel if you 'click' the pivot cell it won't have a regular cell reference. You want underlying cell references, so don't click them. So on a new worksheet tab, you want to create a formula that references the two pivot tables-- here in your references you type in cell formula (in your picture the cells would be something like "$Sheet4!A$4: $Sheet4!?$?") for both of your arrays. you grab the values you want by vlookups, and then divide things as needed.

- - - -
I felt uncomfortable while writing that as it seems we have the wrong tool for the job on two levels here (i.e. explaining this by text with clunky excel interface -- maybe a youtube video would be ok though) and I get less and less happy with spreadsheets as the right tool for anything, but I digress.

Some extra care is needed in dealing with pivot tables, on a few different levels. Not sure how much that helps.
 
  • Like
Likes   Reactions: WWGD
StoneTemplePython said:
I think this is going to be hard to explain over text as excel cells aren't quite standardized enough... (if you were using pandas or numpy in python things are almost taylor made for forum correspondence-- it really would be as simple as dropping in a couple lines of code... )

Does the below sketch work?
- - - -
you have two pivot tables. Linking to pivots is the same as as with regular cells excel if you 'click' the pivot cell it won't have a regular cell reference. You want underlying cell references, so don't click them. So on a new worksheet tab, you want to create a formula that references the two pivot tables-- here in your references you type in cell formula (in your picture the cells would be something like "$Sheet4!A$4: $Sheet4!?$?") for both of your arrays. you grab the values you want by vlookups, and then divide things as needed.

- - - -
I felt uncomfortable while writing that as it seems we have the wrong tool for the job on two levels here (i.e. explaining this by text with clunky excel interface -- maybe a youtube video would be ok though) and I get less and less happy with spreadsheets as the right tool for anything, but I digress.

Some extra care is needed in dealing with pivot tables, on a few different levels. Not sure how much that helps.

Thanks, and sorry I forgot to include this: What makes the ratio A/B more complicated is that B is an aggregate, making a SQL query clunkier ( needing to do group by' s )
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 31 ·
2
Replies
31
Views
4K
  • · Replies 41 ·
2
Replies
41
Views
6K
  • · Replies 20 ·
Replies
20
Views
3K
Replies
8
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K