How to calculate a difference between two value sums in a pivot table

KayB14

New Member
Joined
Jul 9, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I would really appreciate some help on this really manual piece of work and hope there's an easier way. Below is a dummy dataset from data.world that is similar to my real dataset.

I am working on a pivot table and I have two values in the 'values' field - one is the sum of the total number of students and the other is the sum of students who passed. I am looking for a way I can calculate the pass rate (sum of passes/sum of total) in the pivot table instead of doing it manually (as per columns R-T) and get it to look like that. I need to redo it because copying it it to the side I tried using the '% difference from' option in 'Show values as' but this does not give me the option to calculate a difference between value fields.

Student Data dummy.xlsx
JKLMNOPQRST
2Column Labels
32017/182018/192019/202017/182018/192019/20
4Row LabelsSum of Students PassedSum of TotalSum of Students PassedSum of TotalSum of Students PassedSum of TotalPass ratePass ratePass rate
5F33238334939777178586.7%91.1%98.2%
6M24926625327056256593.6%95.1%99.5%
7Grand Total5816496026671,3331,35089.5%92.8%98.7%
Sheet4
Cell Formulas
RangeFormula
R5:R7R5=K5/L5
S5:S7S5=M5/L5
T5:T7T5=O5/P5


In my actual dataset I have to do this multiple times across a much larger pivot table with multiple row labels; so calculating isn't as simple as dragging a formula along. I can drag down but have to repopulate sideways.

FYI: my raw dataset is restricted in that I have sums of total categories (e.g. rather than having one line per student with information of each parameter in the columns, I have the totals of all students who have the same parameter).

Thank you!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Since you have 365, then you can use Power Query, called Get and Transform on the Data Tab

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Added Custom" = Table.AddColumn(#"Promoted Headers", "2017/2018", each [Sum of Students Passed]/[Sum of Total]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "2018/2019", each [Sum of Students Passed_1]/[Sum of Total_2]),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "2019/2020", each [Sum of Students Passed_3]/[Sum of Total_4]),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom2",{{"2017/2018", Percentage.Type}, {"2018/2019", Percentage.Type}, {"2019/2020", Percentage.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Sum of Students Passed", "Sum of Total", "Sum of Students Passed_1", "Sum of Total_2", "Sum of Students Passed_3", "Sum of Total_4"})
in
    #"Removed Columns"
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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