Pivot Table Formula with fluctuating cell data

Sunshine8790

Board Regular
Joined
Jun 1, 2021
Messages
71
Office Version
  1. 365
Platform
  1. Windows
I have a pivot table where an additional column was added on for percentages for each row of data.
Below is the formula for the first 2 rows of data located in columns AG40 through AG48:
Excel Formula:
=AF40/$AF$49
Excel Formula:
=AF41/$AF$49
Excel Formula:
=AF42/$AF$49
Excel Formula:
=AF43/$AF$49
Excel Formula:
=AF44/$AF$49
Excel Formula:
=AF45/$AF$49
Excel Formula:
=AF46/$AF$49
Excel Formula:
=AF47/$AF$49
Excel Formula:
=AF48/$AF$49

Then there is the "Total" row, where the formula in AG49 (where all the above values are being divided by) is:

Excel Formula:
=SUM(AG40:AG48

The trouble is, the data is updated daily - and sometimes there is an extra row or 2 of data, sometimes a row or 2 less of data. Which means sometimes the "Total" line which is currently on row 49, ends up in row 50, or 48, or 51.

Is there a way to change these formulas to work with that kind of fluctuation so that I don't have to keep manually updating it as it changes?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You seem to be mixing 2 different approaches.
If you are using a pivot table you would use the "Show Values as > % of Column Total" and the pivot table handle both the Sum formula and the divide by the Total formulas.
The formulas you are using seem to be those you would use if you are NOT using a pivot table and in that case you would use an Excel Table which would automatically expand and contract with the number of lines and adjust the total and the percentage calculation you are using.

Please provide and XL2BB of your data.
 
Upvote 0
You seem to be mixing 2 different approaches.
If you are using a pivot table you would use the "Show Values as > % of Column Total" and the pivot table handle both the Sum formula and the divide by the Total formulas.
The formulas you are using seem to be those you would use if you are NOT using a pivot table and in that case you would use an Excel Table which would automatically expand and contract with the number of lines and adjust the total and the percentage calculation you are using.

Please provide and XL2BB of your data.
Data below:

FormulaFixForSiteUpdate.xlsx
ABACADAEAFAG
39ProcessUnselectedSelectedWavedTotal%
40Auto-Bagger17514138588917.27%
41Auto-Boxer Standard SPO182118215.34%
42BHLDN83830.24%
43Non-Con442813250.95%
44Rebin4804528500814.69%
45Ship Alone26260.08%
46SIO1522794311.26%
47Sorter3819144671828653.62%
48SPO17362199722326.55%
49Total64453412731534101100.00%
Sheet2
Cell Formulas
RangeFormula
AG40:AG48AG40=AF40/$AF$49
AG49AG49=SUM(AG40:AG48)
 
Upvote 0
How do you feel about creating a % of column total and then hiding columns AF to AH ?
PS: I am in Australia and it is 1am here so will log off soon.

20210905 Pivot PerCentages.xlsx
ABACADAEAFAGAHAIAJ
37ValuesAttribute
38Sum of Value% of Value2Total Sum of ValueTotal % of Value2
39ProcessSelectedUnselectedWavedSelectedUnselectedWaved
40Auto-Bagger175141380.00%27.17%15.15%588917.27%
41Auto-Boxer Standard SPO18210.00%0.00%6.67%18215.34%
42BHLDN830.00%0.00%0.30%830.24%
43Non-Con442810.00%0.68%1.03%3250.95%
44Rebin48045280.00%7.45%16.58%500814.69%
45Ship Alone260.00%0.40%0.00%260.08%
46SIO27915281.82%2.36%0.00%4311.26%
47Sorter3819144670.00%59.26%52.96%1828653.62%
48SPO62173199718.18%2.68%7.31%22326.55%
49Grand Total341644527315100.00%100.00%100.00%34101100.00%
Pivot


1630767799120.png
 
Last edited:
Upvote 0
How do you feel about creating a % of column total and then hiding columns AF to AH ?
PS: I am in Australia and it is 1am here so will log off soon.

20210905 Pivot PerCentages.xlsx
ABACADAEAFAGAHAIAJ
37ValuesAttribute
38Sum of Value% of Value2Total Sum of ValueTotal % of Value2
39ProcessSelectedUnselectedWavedSelectedUnselectedWaved
40Auto-Bagger175141380.00%27.17%15.15%588917.27%
41Auto-Boxer Standard SPO18210.00%0.00%6.67%18215.34%
42BHLDN830.00%0.00%0.30%830.24%
43Non-Con442810.00%0.68%1.03%3250.95%
44Rebin48045280.00%7.45%16.58%500814.69%
45Ship Alone260.00%0.40%0.00%260.08%
46SIO27915281.82%2.36%0.00%4311.26%
47Sorter3819144670.00%59.26%52.96%1828653.62%
48SPO62173199718.18%2.68%7.31%22326.55%
49Grand Total341644527315100.00%100.00%100.00%34101100.00%
Pivot


View attachment 46279

Unable to hide any columns or rows as there are mulitple other pivot tables in the spreadsheet.

Also, I'm not seeing the options in my pivot field list that you screenshotted.
 
Upvote 0
You simply need to drag the field you have in your values box into the values box a second time.
 
Upvote 0
If you don’t want to hide columns but want the number of rows to expand / contract automatically you might need to use the Data Model and Power Pivot. Power Query may be an option as well.
 
Upvote 0
If you don’t want to hide columns but want the number of rows to expand / contract automatically you might need to use the Data Model and Power Pivot. Power Query may be an option as well.
I'm not that advanced at excel to understand what you just suggested. I would need to be instructed step by step on how to do that.
Was really hoping that I could just do something simple within the formula equation itself.
 
Upvote 0
OK give the below a try:
Perhaps create a new sheet, and copy the below to AB36.
The components are:
  • The formula in AG40 needs to be copied to be longer than the most lines you are expecting the pivot table to return.
  • In the formula
    Excel Formula:
    =IF(AB40="","",IF(AB40<>"Total",AF40/GETPIVOTDATA("Value",$A$38),100%))
    highlight the part GETPIVOTDATA("Value",$A$38) a then click on the total in your pivot which in your post #3 picture was AF49.
    If this does not produce a GETPIVOTDATA formula come back to me and I will need to supply more detail.
  • I have then applied conditional formatting to make the % line and the Total line Bold and the same color as the pivot.
    =OR(RIGHT(AB39,5)="Total",AB39="Process")


20210905 Pivot PerCentages.xlsx
ABACADAEAFAG
36
37
38Sum of ValueAttribute
39ProcessSelectedUnselectedWavedTotal%
40Auto-Bagger17514138588917.27%
41Auto-Boxer Standard SPO182118215.34%
42BHLDN83830.24%
43Non-Con442813250.95%
44Rebin4804528500814.69%
45Ship Alone26260.08%
46SIO2791524311.26%
47Sorter3819144671828653.62%
48SPO62173199722326.55%
49Total34164452731534101100.00%
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
Reconstruct Data
Cell Formulas
RangeFormula
AG40:AG63AG40=IF(AB40="","",IF(AB40<>"Total",AF40/GETPIVOTDATA("Value",$A$38),100%))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AG39:AG63Expression=OR(RIGHT(AB39,5)="Total",AB39="Process")textNO
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

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