Efficient Formula for Summing Values Based on Multiple Conditions

irfman

New Member
Joined
Jan 1, 2019
Messages
19
Office Version
  1. 2021
Hi everyone,

I have a large dataset stored in an Excel table, which includes many columns, but for my current query, I am focusing on the following sample structure:

NameTypeFBAmount
SamAY100
SamAN50
SamBY200
SamBY10
TomAN30
TomAN50
TomBY75
TomBN50

I have extracted unique names in Column F using the following formula:

=UNIQUE(db[Name])

Now, I need to retrieve the corresponding sum of Amount for each Type (A & B) where FB is "Y" (Yes), structured as follows:

NameAB
Sam100210
Tom075

I have tried using SUMIFS, and while it works, my dataset is quite large, making the worksheet painfully slow.

I would also like to know if using a helper column could help reduce computations and improve performance.

Can someone suggest an efficient Excel formula to achieve this without slowing down performance?

I’d really appreciate your support and suggestions. Thanks in advance!
 
Timesheet.xlsx
ABCDEFGHIJ
1
2NameTypeFBAmountNameAB
3SamAY100Sam100210
4SamAN50Tom075
5SamBY200
6SamBY10
7TomAN30
8TomAN50
9TomBY75
10TomBN50
11
Sheet2

In G3
Excel Formula:
=LET(a,UNIQUE(B3:B10),b,SUMIFS(E3:E10,C3:C10,H2:I2,D3:D10,"Y",B3:B10,a),c,SUMIFS(E3:E10,C3:C10,I2,D3:D10,"Y",B3:B10,a),HSTACK(a,b,c))
 
Last edited:
Upvote 0
Formula in Post#2 should be read as below
In G2
Excel Formula:
=LET(a,UNIQUE(B3:B10),b,SUMIFS(E3:E10,C3:C10,H2:I2,D3:D10,"Y",B3:B10,a),HSTACK(a,b))
 
Upvote 0
If you are looking for speed, have you tried a Pivot Table?

This situation is perfect for a PT:
Book1
ABCDEFGHIJ
1NameTypeFBAmountFBY
2SamAY100
3SamAN50Sum of AmountColumn Labels
4SamBY200Row LabelsABGrand Total
5SamBY10Sam100210310
6TomAN30Tom7575
7TomAN50Grand Total100285385
8TomBY75
9TomBN50
Sheet1
 
Upvote 0
I have tried using SUMIFS, and while it works, my dataset is quite large, making the worksheet painfully slow.
I have not tested with large data but wondering if, given that you have already tried SUMIFS and that was slow (& same function suggested by @kvsrinivasamurthy ), that using Excel's built-in Pivot Table feature, with a few tweaks, might be worth trying?

irfman_1.xlsm
ABCDEFGHIJK
1NameTypeFBAmountSum of AmountType
2SamAY100NameFBAB
3SamAN50SamY100210
4SamBY200TomY075
5SamBY10
6TomAN30
7TomAN50
8TomBY75
9TomBN50
10
Sheet1
 
Upvote 0

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