How do I set up a weighted average that does not count cells that are empty?

slim6y

Board Regular
Joined
Oct 2, 2012
Messages
78
Hi all,

I am looking to get data from my table of unit costs by putting a weighted average. But after a unit has been moved, I empty a cell meaning I want that removed from the weighted average.

I have this calculation:

Excel Formula:
=IFERROR(SUMPRODUCT(Purchases_XYZ[Cost Per Unit],Purchases_XYZ[Cost])/SUM(Purchases_XYZ[Cost]),"")

This gives me the weighted average. But, if I remove a "[Cost Per Unit]" cell (because I have removed that unit completely) I want that row to be removed from the weighted average.

So I am looking for an "IF" statement perhaps. IF [Cost Per Unit] =< 0 then don't count that in the sumproduct.

How do I write that out?

TIA.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Ok, solved!!!

Excel Formula:
=IFERROR(SUMPRODUCT(Purchases_XYZ[Cost Per Unit],--(Purchases_XYZ[Cost Per Unit]<>0),Purchases_XYZ[Cost])/SUMPRODUCT(Purchases_XYZ[Cost],--(Purchases_XYZ[Cost Per Unit]<>0)),"")
 
Upvote 0
Solution

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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