SUMPRODUCT help

JamesonMH

Board Regular
Joined
Apr 17, 2018
Messages
120
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I've exhausted my options and really need some help with this.

I'm dealing with a fixed payroll table where the column headers duplicate across (but the data is different). Given a bi-weekly income, I want to calculate what the CPP amount is. For example, if income was $2,011.45, then CPP should be $92.90 since it falls between $2,011.28-2,011.47. Obviously if it were just the 3 columns it would be easy, but that's not how the payroll table is.

[TABLE="width: 500"]
<tbody>[TR]
[TD]Bi-weekly income[/TD]
[TD][/TD]
[TD][/TD]
[TD]Bi-weekly income[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]From[/TD]
[TD]To[/TD]
[TD]CPP[/TD]
[TD]From[/TD]
[TD]To[/TD]
[TD]CPP[/TD]
[/TR]
[TR]
[TD]$1,996.33[/TD]
[TD]$1,996.52[/TD]
[TD]$92.16[/TD]
[TD]$2,010.88[/TD]
[TD]$2,011.07[/TD]
[TD]$92.88[/TD]
[/TR]
[TR]
[TD]1,996.53[/TD]
[TD]1,996.73[/TD]
[TD]92.17[/TD]
[TD]2,011.08[/TD]
[TD]2,011.27[/TD]
[TD]92.89[/TD]
[/TR]
[TR]
[TD]1,996.74[/TD]
[TD]1,996.93[/TD]
[TD]92.18[/TD]
[TD]2,011.28[/TD]
[TD]2,011.47[/TD]
[TD]92.90[/TD]
[/TR]
[TR]
[TD]1,996.94[/TD]
[TD]1,997.13[/TD]
[TD]92.19[/TD]
[TD]2,011.48[/TD]
[TD]2,011.68[/TD]
[TD]92.91[/TD]
[/TR]
</tbody>[/TABLE]

I've tried some INDEX/SUMPRODUCT/MIN/IF/ROW arrays but no luck so far.

Please help!

James
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi James,

Is there something preventing you from transposing all your existing Columns ... into the 3 columns you need ... ?

Another worksheet could handle this issue for you ... :wink:
 
Upvote 0
Hi James,

Is there something preventing you from transposing all your existing Columns ... into the 3 columns you need ... ?

Another worksheet could handle this issue for you ... :wink:

I agree with that. Thing is there's many pages of this source data (payroll table) with more columns than in my example...so I'm hoping to have a cleaner/single cell solution that leaves source data in check, finds the correct income range and just returns the CPP rate.

Plus I won't be the only one using so training others how to tranpose/manipulate (even though pretty simple) source data just raises risk of errors.
 
Upvote 0
May I ask you How Many Columns in total do you have in your Payroll table ...???
 
Upvote 0
Let A1:F5 house the data with headers in A1:F1.

A8: $2,011.45

In B8 control+shift+enter, not just enter:

=MIN(IF(MOD(COLUMN($A$2:$E$5)-COLUMN($A$2:$A$5),3)=0,IF(A8>=$A$2:$E$5,IF(A8<=$B$2:$F$5,COLUMN($A$2:$E$5)))))

In C8 control+shift+enter, not just enter:

=VLOOKUP(A8,CHOOSE({1,2},INDEX($A$2:$F$5,0,B8),INDEX($A$2:$F$5,0,B8+2)),2,1)
 
Upvote 0
Assuming you have lookup table like this:


Book1
ABCDEFGHI
1FromToCPPFromToCPPFromToCPP
21996.331996.5292.162010.882011.0792.882011.692011.8892.92
31996.531996.7392.172011.082011.2792.892011.892012.0892.93
41996.741996.9392.182011.282011.4792.902012.092012.2892.94
51996.941997.1392.192011.482011.6892.912012.292012.4892.95
Sheet1



Then you can use this:


Book1
AB
7IncomeCPP
82011.4592.90
91996.8592.18
102011.9592.93
112011.1592.89
Sheet1
Cell Formulas
RangeFormula
B8{=A8-MAX(ABS(IF((A8>=$A$2:$I$5)*(A8<=$B$2:$J$5),$C$2:$K$5,A8)-A8))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Another Option:

Data Table

Book1
ABCDEFGHI
1FromToCPPFromToCPPFromToCPP
21996.331996.5292.162010.882011.0792.882011.692011.8892.92
31996.531996.7392.172011.082011.2792.892011.892012.0892.93
41996.741996.9392.182011.282011.4792.902012.092012.2892.94
51996.941997.1392.192011.482011.6892.912012.292012.4892.95
Sheet1


Result:

Book1
AB
7IncomeCPP
82011.4592.90
91996.8592.18
102012.1992.94
112011.1592.89
Sheet1
Cell Formulas
RangeFormula
B8=AGGREGATE(14,,((A8>=$A$2:$I$5)*(A8<=$B$2:$J$5)*MOD(COLUMN($A$2:$I$5)*(ROW($A$2:$A$5)^0),3)=1)*$C$2:$K$5,1)
 
Upvote 0
For sure...it's 12 columns (double my example) by 35 pages...

Well,

With 35 individual worksheets showing 12 Columns each ... you are talking about an extremely sophisticated ' Payroll ' system ...!!! :smile:

For sure, it will be much safer to build a reference database ...!!!
 
Upvote 0
Assuming you have lookup table like this:

ABCDEFGHI

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]From[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]To[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]CPP[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]From[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]To[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]CPP[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]From[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]To[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]CPP[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]1996.33[/TD]
[TD="align: right"]1996.52[/TD]
[TD="align: right"]92.16[/TD]
[TD="align: right"]2010.88[/TD]
[TD="align: right"]2011.07[/TD]
[TD="align: right"]92.88[/TD]
[TD="align: right"]2011.69[/TD]
[TD="align: right"]2011.88[/TD]
[TD="align: right"]92.92[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]1996.53[/TD]
[TD="align: right"]1996.73[/TD]
[TD="align: right"]92.17[/TD]
[TD="align: right"]2011.08[/TD]
[TD="align: right"]2011.27[/TD]
[TD="align: right"]92.89[/TD]
[TD="align: right"]2011.89[/TD]
[TD="align: right"]2012.08[/TD]
[TD="align: right"]92.93[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]1996.74[/TD]
[TD="align: right"]1996.93[/TD]
[TD="align: right"]92.18[/TD]
[TD="align: right"]2011.28[/TD]
[TD="align: right"]2011.47[/TD]
[TD="align: right"]92.90[/TD]
[TD="align: right"]2012.09[/TD]
[TD="align: right"]2012.28[/TD]
[TD="align: right"]92.94[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]1996.94[/TD]
[TD="align: right"]1997.13[/TD]
[TD="align: right"]92.19[/TD]
[TD="align: right"]2011.48[/TD]
[TD="align: right"]2011.68[/TD]
[TD="align: right"]92.91[/TD]
[TD="align: right"]2012.29[/TD]
[TD="align: right"]2012.48[/TD]
[TD="align: right"]92.95[/TD]

</tbody>
Sheet1




Then you can use this:

AB

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]7[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]Income[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00B0F0]#00B0F0[/URL] , align: center"]CPP[/TD]

[TD="align: center"]8[/TD]
[TD="align: right"]2011.45[/TD]
[TD="align: right"]92.90[/TD]

[TD="align: center"]9[/TD]
[TD="align: right"]1996.85[/TD]
[TD="align: right"]92.18[/TD]

[TD="align: center"]10[/TD]
[TD="align: right"]2011.95[/TD]
[TD="align: right"]92.93[/TD]

[TD="align: center"]11[/TD]
[TD="align: right"]2011.15[/TD]
[TD="align: right"]92.89[/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B8[/TH]
[TD="align: left"]{=A8-MAX(ABS(IF((A8>=$A$2:$I$5)*(A8<=$B$2:$J$5),$C$2:$K$5,A8)-A8))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]

Brilliant! This is much cleaner than what I was attempting. Much appreciated Nishant! I'll take a look at your AGGREGATE solution as well. Thank you!:)
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,435
Members
452,326
Latest member
johnshaji

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