Find Avg of weighted values, dependent on multiple criteria, with weightings in 3rd table

butterpouch

New Member
Joined
Aug 16, 2017
Messages
2
Hi Guys,
First post, hope I'm doing this right!


I have Table1 which contains the values I need to Average into a column in Table2. The selection of rows in Table1 for the Avg is based on multiple criteria matching every row of Table2.


My problem is with solving the requirement for me to use weighting in the Average calculation. Table1 contains two columns, which combined can be used to look up matching values in a third table, Table3. Table3 provides the weighting value that I want to use in Table2's function that gets the Average from Table1.


Normally I would have accomplished this using Sumproduct, so naturally I tried to add an Index Match Array function to get the weighting value and multiple against the avg column, but because I have multiple criteria I needed to use an array function, and gave an error, which I think is because Sumproduct can't be used that way.


Here's my function in [Table2]:
=SUMPRODUCT(
Table1[Cost] *
([@Provider]= Table1[Provider]) *
([@Term]= Table1[Term])
) /
COUNTIFS(
Table1[Provider], [@Provider],
Table1[Term], [@Term])


Here's the formula that does not work where I've attempted to get the weight:
=SUMPRODUCT(
(Table1[Cost] * INDEX(Table3[Weight], MATCH(1, (Table1[Provider] = Table3[Provider]) * ( Table1[Category] = Table3[Category]), 0))) *
([@Provider] = Table1[Provider]) *
([@Term] = Table1[Term])
) /
COUNTIFS(
Table1[Provider], [@Provider],
Table1[Term], [@Term])


This also doesn't work:
=SUMPRODUCT(
Table1[Cost] *
([@Provider]= Table1[Provider]) *
([@Term]= Table1[Term]) ,
(Table1[Category] = Table3[Category]) *
([Provider] = Table3[Provider])
) /
COUNTIFS(
Table1[Provider], [@Provider],
Table1[Term], [@Term])




Spreadsheet attached with example.


Thank you!

[TABLE="width: 805"]
<colgroup><col><col span="2"><col><col><col span="2"><col><col><col><col span="2"></colgroup><tbody>[TR]
[TD]Table1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Table2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Table3[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Provider[/TD]
[TD]Term[/TD]
[TD]Cost[/TD]
[TD]Category[/TD]
[TD][/TD]
[TD]Provider[/TD]
[TD]Term[/TD]
[TD]Average Weighted Cost[/TD]
[TD][/TD]
[TD]Provider[/TD]
[TD]Category[/TD]
[TD]Weight[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]32.9519[/TD]
[TD]R[/TD]
[TD][/TD]
[TD]Yellow[/TD]
[TD="align: right"]2[/TD]
[TD="align: center"]#N/A[/TD]
[TD][/TD]
[TD]Yellow[/TD]
[TD]R[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]32.9519[/TD]
[TD]R[/TD]
[TD][/TD]
[TD]Red[/TD]
[TD="align: right"]3[/TD]
[TD="align: center"]#N/A[/TD]
[TD][/TD]
[TD]Red[/TD]
[TD]R[/TD]
[TD="align: right"]0.3[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]32.9519[/TD]
[TD]R[/TD]
[TD][/TD]
[TD]Green[/TD]
[TD="align: right"]1[/TD]
[TD="align: center"]#N/A[/TD]
[TD][/TD]
[TD]Red[/TD]
[TD]G[/TD]
[TD="align: right"]0.7[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]12.9519[/TD]
[TD]G[/TD]
[TD][/TD]
[TD]Blue[/TD]
[TD="align: right"]2[/TD]
[TD="align: center"]#N/A[/TD]
[TD][/TD]
[TD]Green[/TD]
[TD]R[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]12.9519[/TD]
[TD]G[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Blue[/TD]
[TD]R[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]12.9519[/TD]
[TD]G[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Yellow[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Yellow[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Yellow[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]30.9562[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]30.9562[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]30.9562[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Solution to my problem:

Code:
{=SUMPRODUCT((Table1[Provider]=[@Provider])*(Table1[Term]=[@Term])*IF(Table1[Provider]=TRANSPOSE(Table3[Provider]),IF(Table1[Category]=TRANSPOSE(Table3[Category]),TRANSPOSE(Table3[Weight])*Table1[Cost],0),0))}

Hi Guys,
First post, hope I'm doing this right!


I have Table1 which contains the values I need to Average into a column in Table2. The selection of rows in Table1 for the Avg is based on multiple criteria matching every row of Table2.


My problem is with solving the requirement for me to use weighting in the Average calculation. Table1 contains two columns, which combined can be used to look up matching values in a third table, Table3. Table3 provides the weighting value that I want to use in Table2's function that gets the Average from Table1.


Normally I would have accomplished this using Sumproduct, so naturally I tried to add an Index Match Array function to get the weighting value and multiple against the avg column, but because I have multiple criteria I needed to use an array function, and gave an error, which I think is because Sumproduct can't be used that way.


Here's my function in [Table2]:
=SUMPRODUCT(
Table1[Cost] *
([@Provider]= Table1[Provider]) *
([@Term]= Table1[Term])
) /
COUNTIFS(
Table1[Provider], [@Provider],
Table1[Term], [@Term])


Here's the formula that does not work where I've attempted to get the weight:
=SUMPRODUCT(
(Table1[Cost] * INDEX(Table3[Weight], MATCH(1, (Table1[Provider] = Table3[Provider]) * ( Table1[Category] = Table3[Category]), 0))) *
([@Provider] = Table1[Provider]) *
([@Term] = Table1[Term])
) /
COUNTIFS(
Table1[Provider], [@Provider],
Table1[Term], [@Term])


This also doesn't work:
=SUMPRODUCT(
Table1[Cost] *
([@Provider]= Table1[Provider]) *
([@Term]= Table1[Term]) ,
(Table1[Category] = Table3[Category]) *
([Provider] = Table3[Provider])
) /
COUNTIFS(
Table1[Provider], [@Provider],
Table1[Term], [@Term])




Spreadsheet attached with example.


Thank you!

[TABLE="width: 805"]
<tbody>[TR]
[TD]Table1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Table2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Table3[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Provider[/TD]
[TD]Term[/TD]
[TD]Cost[/TD]
[TD]Category[/TD]
[TD][/TD]
[TD]Provider[/TD]
[TD]Term[/TD]
[TD]Average Weighted Cost[/TD]
[TD][/TD]
[TD]Provider[/TD]
[TD]Category[/TD]
[TD]Weight[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]32.9519[/TD]
[TD]R[/TD]
[TD][/TD]
[TD]Yellow[/TD]
[TD="align: right"]2[/TD]
[TD="align: center"]#N/A[/TD]
[TD][/TD]
[TD]Yellow[/TD]
[TD]R[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]32.9519[/TD]
[TD]R[/TD]
[TD][/TD]
[TD]Red[/TD]
[TD="align: right"]3[/TD]
[TD="align: center"]#N/A[/TD]
[TD][/TD]
[TD]Red[/TD]
[TD]R[/TD]
[TD="align: right"]0.3[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]32.9519[/TD]
[TD]R[/TD]
[TD][/TD]
[TD]Green[/TD]
[TD="align: right"]1[/TD]
[TD="align: center"]#N/A[/TD]
[TD][/TD]
[TD]Red[/TD]
[TD]G[/TD]
[TD="align: right"]0.7[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]12.9519[/TD]
[TD]G[/TD]
[TD][/TD]
[TD]Blue[/TD]
[TD="align: right"]2[/TD]
[TD="align: center"]#N/A[/TD]
[TD][/TD]
[TD]Green[/TD]
[TD]R[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]12.9519[/TD]
[TD]G[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Blue[/TD]
[TD]R[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]12.9519[/TD]
[TD]G[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Yellow[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Yellow[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Yellow[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]31.1992[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]30.9562[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]30.9562[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Blue[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]30.9562[/TD]
[TD]R[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

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