Formula to Sum a Group based on Blank Spaces between Groups

secrestj

New Member
Joined
Feb 18, 2005
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Forum members: I have exhausted my internet/forum searches and AI formula assistance on my issue and turning to you. Thank you for your help in advance. I am looking for formula and not VBA. I am using Office 365.

I want to have a formula that I can drag down rows (in Column C) that will return the sum of a group of another column (Column B) based on a blank cell between the groups (Column B). The groups vary in size (my example shows 3 and 4 categories), with some having 2 to 7 categories within a grouping. I have oversimplified then table for the Forum Members use. I will change the formula as necessary to differing columns or changes in formula operations (e.g. sum to percentage calculations), but I need to BASE formula to start with. I have tried numerous ways and failed. Also, looking for the formula to be in a single cell and not rely on a 'helper column'.

For the cells in Column C between totals, I want it to return blank (or ""), as I want to be able to drop the formula into any spreadsheet provided to me and put the formula at the top and drag to obtain quick results to report on.

I hope this is not too much a lift and the members can help. Thank you again. See sample table below.
 

Attachments

  • Screenshot 2025-01-17 at 1.24.49 PM.png
    Screenshot 2025-01-17 at 1.24.49 PM.png
    22.5 KB · Views: 9

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I am using Office 365.
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

How about
Excel Formula:
=IF(B2="",SUM(C$2:C2)-SUM(D$1:D1),"")
 
Upvote 0
Another option:

Excel Formula:
=LET(
r,C2:C19,
a,SCAN(0,r,LAMBDA(x,y,IF(y="",0,x+y))),
b,VSTACK(0,DROP(a,-1)),
IF(r<>"","",b))
 
Upvote 0
pile on:

MrExcelPlayground23.xlsx
ABCD
1TypeStatusamount
2ax20 
3bx40 
4cx30 
5total 190
6at20 
7bt10 
8ct10 
9total 240
10qx50 
11wx10 
12ex30 
13rx40 
14total 3130
15qt10 
16wt10 
17et20 
18rt50 
19total 490
Sheet28
Cell Formulas
RangeFormula
D2D2=IF(C2<>"","",SUM(DROP(C1:C$2,IFNA(XMATCH(,C1:C$2,0,-1),0))))
D3:D19D3=IF(C3<>"","",SUM(DROP(C$2:C2,IFNA(XMATCH(,C$2:C2,0,-1),0))))


Someday AI will be better at this. But today is not that day.
 
Upvote 0
Solution
Wow - as usual, the Forum Member pull through. I thank Fluff for the recommendation on updating my account and formula; I am running with JamesCanale's version, as I understand it - thank you. However, I just ran hagia_sofia version and amazing - I am going to do much more research in breaking down this formula and its potential future applications - I am always learning from everyones' various approaches to the same problem.

Thank you for each of your efforts. This is a great forum.
 
Upvote 0
Glad we could help & thanks for the feedback.


Does that mean you don't understand the formula I suggested?
No - you misunderstood. I went with the JamesCanale version, as I believe I can adapt it for my other formula changes I need. I am still working it to see if it works for me. Thank you for your follow up.
 
Upvote 0

Forum statistics

Threads
1,225,606
Messages
6,185,956
Members
453,333
Latest member
BioCoder84

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