sumproduct

tabspace

New Member
Joined
Oct 23, 2017
Messages
16
I have the following data:
FileDownloadHandler.ashx

I would like to use sumproduct based on day of the week but also replacing the Hi, Mid and Lo with their correct values.

For example, for Paul, the total of his Mondays, should be 1*100+3*1+1*1

Any ideas?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Re: sumproduct - advanced difficulty

If you Sort the table in H2:I4 in Ascending order by column H ( so it goes hi lo mid)

Try this array formula entered with CTRL + SHIFT + ENTER

=SUM(($B$1:$F$1="Monday")*LOOKUP(B3:F3,$J$2:$K$4)*$B$2:$F$2)
 
Last edited:
Upvote 0
Re: sumproduct - advanced difficulty

If you use SUMIF you can leave the lookup table as it is, i.e.

=SUMPRODUCT((B$1:F$1="Monday")+0,B$2:F$2,SUMIF(H$2:H$4,B3:F3,I$2:I$4))
 
Upvote 0
Re: sumproduct - advanced difficulty

Sorry Jonmo1this didn't help. Thanks anyway!
 
Last edited:
Upvote 0
Re: sumproduct - advanced difficulty

Hi Barry,

This worked perfectly well! Can you explain to me why the +0? If I remove it, the formula doesn't work anymore.

Thanks again!

If you use SUMIF you can leave the lookup table as it is, i.e.

=SUMPRODUCT((B$1:F$1="Monday")+0,B$2:F$2,SUMIF(H$2:H$4,B3:F3,I$2:I$4))
 
Upvote 0
Re: sumproduct - advanced difficulty

It looks like I changed the location of the lookup table from your post..
=SUM(($B$1:$F$1="Monday")*LOOKUP(B3:F3,$J$2:$K$4)*$B$2:$F$2)
According to the picture in your post, That should have been
=SUM(($B$1:$F$1="Monday")*LOOKUP(B3:F3,$H$2:$I$4)*$B$2:$F$2)

Also remember it's an array formula that requires a special key combination to enter it.
Instead of just pressing Enter, you press CTRL + SHIFT + ENTER
You'll know it's correctly entered when the formula is enclosed in {brackets}

Here's how it should look


Book1
ABCDEFGHI
1MondayMondayTuesdayFridayMondaylookuptable
2Incentive day13241hi100
3PaulHiLoHiMidLo104lo1
4PeterMidHiLoHIMid400mid50
5SusanMidLoHiHiHi153
Sheet1
Cell Formulas
RangeFormula
G3{=SUM(($B$1:$F$1="Monday")*LOOKUP(B3:F3,$H$2:$I$4)*$B$2:$F$2)}
G4{=SUM(($B$1:$F$1="Monday")*LOOKUP(B4:F4,$H$2:$I$4)*$B$2:$F$2)}
G5{=SUM(($B$1:$F$1="Monday")*LOOKUP(B5:F5,$H$2:$I$4)*$B$2:$F$2)}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Re: sumproduct - advanced difficulty

And come to think of it, change SUM to SUMPRODUCT and it no longer requires the Array Entry
=SUMPRODUCT(($B$1:$F$1="Monday")*LOOKUP(B3:F3,$H$2:$I$4)*$B$2:$F$2)
 
Upvote 0
Re: sumproduct - advanced difficulty

Thanks Jonmo1! For some reason I can't get your formula to work :(

I get N/A
 
Upvote 0
Re: sumproduct - advanced difficulty

Can you explain to me why the +0? If I remove it, the formula doesn't work anymore.

Using this approach

=SUMPRODUCT((B$1:F$1="Monday")+0,B$2:F$2,SUMIF(H$2:H$4,B3:F3,I$2:I$4))

The (B$1:F$1="Monday") part returns an array of TRUE/FALSE values. For SUMPRODUCT to work as required we need those to be 1/0 values so using +0 is one way to make that conversion - an alternative is to multiply some of the conditions in the formula, e.g. with this revised syntax

=SUMPRODUCT((B$1:F$1="Monday")*SUMIF(H$2:H$4,B3:F3,I$2:I$4),B$2:F$2)
 
Upvote 0
Re: sumproduct - advanced difficulty

Thanks for the explanation!

Using this approach

=SUMPRODUCT((B$1:F$1="Monday")+0,B$2:F$2,SUMIF(H$2:H$4,B3:F3,I$2:I$4))

The (B$1:F$1="Monday") part returns an array of TRUE/FALSE values. For SUMPRODUCT to work as required we need those to be 1/0 values so using +0 is one way to make that conversion - an alternative is to multiply some of the conditions in the formula, e.g. with this revised syntax

=SUMPRODUCT((B$1:F$1="Monday")*SUMIF(H$2:H$4,B3:F3,I$2:I$4),B$2:F$2)
 
Upvote 0

Forum statistics

Threads
1,216,590
Messages
6,131,610
Members
449,657
Latest member
Timber5

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