Is there a way to generate a dynamic table of subtotals?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,533
Office Version
  1. 365
Platform
  1. Windows
Is there a way to generate a dynamic table of subtotals from the data in another table?

The table on the left contains donations made to several people during 2021. The table on the right shows the subtotals for each of these people. Is there a way to generate the table on the right dynamically -- that is, without me having to enter each name on its own row -- so that if I add a new donation to a new person in the table on the left, the table on the right will automatically grow a new row? Thanks

Donations & RMD.xlsx
BCDEFG
5DateToAmountNameYear Total
62/03/21 Susie$100Freddie$800
72/14/21 Freddie$200Johnny$100
83/13/21 Freddie$200Molly$700
94/01/21 Susie$100Susie$400
105/22/21 Molly$300Total$2,000
116/15/21 Molly$200
126/19/21 Johnny$100
137/07/21 Molly$100
148/31/21 Freddie$300
159/09/21 Susie$200
169/21/21 Freddie$100
1712/22/21 Molly$100
18Total$2,000
Test2
Cell Formulas
RangeFormula
G6:G9G6=SUMIFS(Table1[Amount],Table1[To],"=" & [@Name])
G10G10=SUBTOTAL(109,[Year Total])
D18D18=SUBTOTAL(109,[Amount])
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I think it in unlikely that you will be able to get the result you want in a Table format without using code.
A pivot table is going to get closest to what you have.
You could use Dynamic array formulas but the output won't be in a table and hence you won't have an automated total line.

20220308 Summary Table Unique.xlsx
BCDEFG
5DateToAmountNameYear Total
603-Feb-21Susie100Susie400
704-Feb-21Freddie200Freddie800
805-Feb-21Freddie200Molly700
906-Feb-21Susie100Johnny100
1007-Feb-21Molly300Additional500
1108-Feb-21Molly200
1209-Feb-21Johnny100
1310-Feb-21Molly100
1411-Feb-21Freddie300
1512-Feb-21Susie200
1613-Feb-21Freddie100
1714-Feb-21Molly100
1808-Mar-22Additional500
19Total2500
Sheet2
Cell Formulas
RangeFormula
F6:F10F6=UNIQUE(Table1[To])
G6:G10G6=SUMIFS(Table1[Amount],Table1[To],F6#)
D19D19=SUBTOTAL(109,[Amount])
Dynamic array formulas.
 
Upvote 0
Solution
I think it in unlikely that you will be able to get the result you want in a Table format without using code.
A pivot table is going to get closest to what you have.
You could use Dynamic array formulas but the output won't be in a table and hence you won't have an automated total line.
That's what I was afraid of. I might take a shot at writing some code. I'll also try my hand at your solution.

Thanks
 
Upvote 0
N.B. No numbers in range G12:G20

Sumifs.xlsm
ABCDEFG
1
2Total52005200
3
4
5DateToAmountNameYear Total
63-Feb-21Susie100Freddie800
714-Feb-21Freddie200George1000
813-Mar-21Freddie200Johnny100
91-Apr-21Susie100Molly900
1022-May-21Molly300Susie400
1115-Jun-21Molly200William2000
1219-Jun-21Johnny100
137-Jul-21Molly100
1431-Aug-21Freddie300
159-Sep-21Susie200
1621-Sep-21Freddie100
1722-Dec-21Molly100
1823-Dec-21Molly200
1924-Dec-21George1000
2022-Dec-21William2000
1d
Cell Formulas
RangeFormula
D2D2=SUBTOTAL(109,Table1[Amount])
G2G2=SUM(G6:G20)
F6:F11F6=SORT(UNIQUE(Table1[To]))
G6:G11G6=SUMIFS(Table1[Amount],Table1[To],F6#)
Dynamic array formulas.
 
Upvote 0
Sumifs.xlsm
ABCDEFG
1
2Total46004600
3
4
5DateToAmountNameYear Total
63-Feb-21Susie100Bill500
714-Feb-21Freddie200Carole1200
813-Mar-21Freddie200Freddie500
91-Apr-21Susie100George1000
1022-May-21Molly300Johnny100
1115-Jun-21Molly200Molly900
1219-Jun-21Johnny100Susie400
137-Jul-21Molly100
149-Sep-21Susie200
1521-Sep-21Freddie100
1622-Dec-21Molly100
1723-Dec-21Molly200
1824-Dec-21George1000
1931-Dec-21Bill500
2031-Dec-21Carole1200
1d
Cell Formulas
RangeFormula
D2D2=SUBTOTAL(109,Table1[Amount])
G2G2=SUM(G6:INDEX(G:G,6+SUM(1/COUNTIF(Table1[To], Table1[To]))))
F6:F12F6=SORT(UNIQUE(Table1[To]))
G6:G12G6=SUMIFS(Table1[Amount],Table1[To],F6#)
Dynamic array formulas.
 
Upvote 0
This result is not a formal table but acts like one in that it will expand/contract with the data in the original (formal) table, like Alex's.
This one includes the sorting of Names (like Dave's) and bottom Total row as shown in your desired results.

22 03 08.xlsm
BCDEFG
5DateToAmountNameYear Total
63/02/2021Susie100Freddie800
714/02/2021Freddie200Johnny100
813/03/2021Freddie200Molly700
91/04/2021Susie100Susie400
1022/05/2021Molly300Total2000
1115/06/2021Molly200
1219/06/2021Johnny100
137/07/2021Molly100
1431/08/2021Freddie300
159/09/2021Susie200
1621/09/2021Freddie100
1722/12/2021Molly100
18Total2000
ST
Cell Formulas
RangeFormula
F6:F10F6=FILTERXML("<p><c>"&TEXTJOIN("</c><c>",1,SORT(UNIQUE(Table1[To])),"Total")&"</c></p>","//c")
G6:G10G6=SUMIFS(Table1[Amount],Table1[To],IF(F6#="Total","*",F6#))
D18D18=SUBTOTAL(109,[Amount])
Dynamic array formulas.
 
Upvote 0
Variation on Peter's if you have LET, LAMBDA and BYROW:

F6:
Excel Formula:
=LET(names,FILTERXML("<p><c>"&TEXTJOIN("</c><c>",1,SORT(UNIQUE(Table1[To])),"Total")&"</c></p>","//c"),CHOOSE({1,2},names,BYROW(names,LAMBDA(a,SUMIF(Table1[To],IF(a="Total","*",a),Table1[Amount])))))
 
Upvote 0
Using some of Rory's changes but without the need for LAMBDA/BYROW?

Excel Formula:
=LET(To,Table1[To],names,FILTERXML("<p><c>"&TEXTJOIN("</c><c>",1,SORT(UNIQUE(To)),"Total")&"</c></p>","//c"),CHOOSE({1,2},names,SUMIF(To,IF(names="Total","*",names),Table1[Amount])))
 
Upvote 0
The =SUBTOTAL(109,[Amount]) obviously works. How is it entered?
My system will not accept the formula but =SUBTOTAL(109,Table1[Amount]) does work.
 
Upvote 0

Forum statistics

Threads
1,215,113
Messages
6,123,165
Members
449,099
Latest member
bes000

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