SUMIF with LEFT and RIGHT Matrix

Alohadboy

New Member
Joined
Mar 18, 2011
Messages
26
Need help with a formula that would be a dynamic SUMIF of sorts. I have a dataset of GL codes (XX-XXXX-XXXXX) for which I need to sum amounts based on the values in two columns.


The left two segments (7 characters) represent the Business Unit and each Business Unit can have multiple GL Codes. To avoid complication, I would like to be able to sum all totals where the Business Unit matches and where the GL code is in the lookup range (Wages, Direct). Sure would be nice to post an example of the worksheet.


I think the formula would look something like this in cell C9, but this obviously doesn't work:


=SUMIFS(G9:G14, LEFT(F9:F14, 7)=B9, RIGHT(F9:F14, 5)=*C2:C6*)
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I can't open the website excelforum.

What stored in C2:C6?

I think the final solution seems like
Code:
=SUMPRODUCT(G9:G14*(LEFT(F9:F14,7)=B9)*(COUNTIF(C2:C6,"*"&F9:F14&"*")>0))
 
Upvote 0

Book1
ABCDEFG
1GL CodeWagesDirect
2Driver5010050200
3Admin5010150201
4Overtime5010250202
5Vacation5010350203
6Bonus5010450204
7
8Business UnitAMOUNTAMOUNTDATA
9Accounting01-0100160070001-0100-50100$500.00
10Customer Service01-0101200001-0100-50102$100.00
11Mgmt01-01020001-0100-50104$100.00
12Contracted Mgmt01-01030001-0101-50100$200.00
13Third Party01-01040001-0100-50202$700.00
1401-0100-50103$900.00
Lookup


In C9 control+shift+enter, not just enter, copy across, and down:

=SUM(IF(ISNUMBER(MATCH($F$9:$F$14,$B9&"-"&C$2:C$6,0)),$G$9:$G$14))
 
Upvote 0
ABCDEFG
GL Code
Driver
Admin
Overtime
Vacation
Bonus
Business UnitDATA
Accounting01-0100-50100
Customer Service01-0100-50102
Mgmt01-0100-50104
Contracted Mgmt01-0101-50100
Third Party01-0100-50202
01-0100-50103

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]

[TD="align: center"] Wages [/TD]
[TD="align: center"] Direct [/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: right"][/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50100[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50200[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50101[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50201[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]
[TD="align: right"][/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50102[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50202[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]
[TD="align: right"][/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50103[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50203[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50104[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] , align: center"]50204[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]

[TD="align: right"][/TD]
[TD="align: center"]AMOUNT[/TD]
[TD="align: center"]AMOUNT[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]9[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] "]01-0100[/TD]
[TD="align: right"]1600[/TD]
[TD="align: right"]700[/TD]
[TD="align: right"][/TD]

[TD="align: right"] $500.00 [/TD]

[TD="align: center"]10[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] "]01-0101[/TD]
[TD="align: right"]200[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]

[TD="align: right"] $100.00 [/TD]

[TD="align: center"]11[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] "]01-0102[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]

[TD="align: right"] $100.00 [/TD]

[TD="align: center"]12[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] "]01-0103[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]

[TD="align: right"] $200.00 [/TD]

[TD="align: center"]13[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=AEAAAA]#AEAAAA[/URL] "]01-0104[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]

[TD="align: right"] $700.00 [/TD]

[TD="align: center"]14[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"] $900.00 [/TD]

</tbody>
Lookup



In C9 control+shift+enter, not just enter, copy across, and down:

=SUM(IF(ISNUMBER(MATCH($F$9:$F$14,$B9&"-"&C$2:C$6,0)),$G$9:$G$14))

Works perfectly. Thanks for the help.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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