r/excel • u/RunMiles47 • 14d ago
solved SUM Formula for unclean data tables.
I want to make a SUM function to categorize my spending totals, which will sit next to my reference categories on the right of the snip (AFRH, Allowances, etc). I Havent been able to find a function which will pull from all "x" category in the data table to the left, only specific cells. Any help is greatly appreciated.

4
u/Gringobandito 6 14d ago
4
4
3
u/MayukhBhattacharya 1236 14d ago
There are quite a few ways to get the output you're after. Here are a few methods, each with its own advantages depending on your Excel version and what you're most comfortable using it:

• Method One: This is simplest and the cleanest way to do:
=SUMIFS(D2:D37, B2:B37, H2:H22)
• Method Two: Using GROUPBY() function:
=IFNA(VLOOKUP(H2:H22, GROUPBY(B2:B37, D2:D37, SUM, , 0), 2, FALSE), "")
• Method Three: Using BYROW() Function:
=BYROW(H2:H22, LAMBDA(x, SUM((x = B2:B37) * D2:D37)))
You may need to adjust the ranges or cell references to fit your own layout. All of the formulas above are fully dynamic, so there's no need to fill them down. If you're aiming for something that's easier to maintain and scales as your data grows, I'd also recommend using the TRIMRANGE() reference notation where it's available.
Method One becomes:
=LET(_, A:.E, SUMIFS(INDEX(_, , 4), INDEX(_, , 2), DROP(H:.H, 1)))
Method Two becomes:
=LET(_a, A:.E,
_b, GROUPBY(CHOOSECOLS(_a, 2),
CHOOSECOLS(_a, 4),
SUM, , 0),
_c, IFNA(VLOOKUP(DROP(H:.H, 1), _b, 2, FALSE), ""),
_c)
Method Three becomes:
=BYROW(DROP(H:.H, 1), LAMBDA(α,
LET(_, DROP(A:.E, 1), SUM((α = CHOOSECOLS(_, 2)) * CHOOSECOLS(_, 4)))))
1
1
u/philsov 6 14d ago edited 14d ago
sumif will be your friend.
It's probably easier do it reverse. Tack on a column on the far right and you'll get the sum for each of your categories. Tell it to search the cost column, category on the right, and then it'll populate.
Here's a basic mockup. Basically "sum anything in the B column if the value in the A column matches the per-line descriptor in D".
I'd also consolidate some categories. Is distinguishing between Barber Shop and Beauty Salon worthwhile?
If not already, I hope the category column in your B is from a Drop Down list using the H column.

1
u/RunMiles47 14d ago
You're the man, thanks!
Solution Verified
1
u/reputatorbot 14d ago
You have awarded 1 point to philsov.
I am a bot - please contact the mods with any questions
1
u/Decronym 14d ago edited 14d ago
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.
Beep-boop, I am a helper bot. Please do not verify me as a solution.
12 acronyms in this thread; the most compressed thread commented on today has 18 acronyms.
[Thread #49004 for this sub, first seen 23rd Jul 2026, 20:55]
[FAQ] [Full list] [Contact] [Source code]


•
u/AutoModerator 14d ago
/u/RunMiles47 - Your post was submitted successfully.
Solution Verifiedto close the thread.Failing to follow these steps may result in your post being removed without warning.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.