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]
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]