Home » excel » excel – Custom SUMPRODUCT()

# excel – Custom SUMPRODUCT()

Questions:

I have the following table: My objective is to spread out the 10,000 units across the 5 months, given the weightings below each month. The row adjacent the 10,000 is my best attempt at getting this (I have spent a few hours on this). The yellow is what I am after.

The logic I have tried to use to get the calculation is as follows: Calculate the even spread across the months (in this example 10,000 / 5 = 2,000 = X). Multiply each month weighting to get the weighted amount (in this example to get M2 = 1,600 and M4 = 3,000: X + (X * M2 weighting) etc). You can then take the total 10,000 minus the summation of these which will give you 5,400, which you can then distribute across the months don’t don’t have a weighting. There must be an easy way to do this with a `SUMPRODUCT` but I can’t seem to figure it out.

My best attempt so far is this:

`=IF(B3=0,SUMPRODUCT(ABS((10000/5)*\$B3:\$F3)),(10000/5)+((10000/5)*B3))`

Try the following: Formula in `B3`:

``````=IF(B\$2=0,(\$A3-SUMPRODUCT((\$B2:\$F2<>0)*((\$A3/5)*(1+\$B2:\$F2))))/COUNTIF(\$B2:\$F2,0),(\$A3/5)*(1+B\$2))
``````

Drag right.

Logic:

• `=IF(B\$2=0,<true>,<false>)` – Check if cell above equals zero
• If above is false (so other than 0) then: `(\$A3/5)*(1+B\$2)` – First divide `(10000/5)` and multiply that outcome by `(1-<percentage>)`
• If `IF` yields true – Check which cells in range are other than zero and multiply by the same logic as per step 2. The sum gained with `SUMPRODUCT` can then be deducted from 10000 and devided by the count of cells that actually do hold zero (hence the `COUNTIF`).