SOLVED

Weighted Average with multiple criteria and looking for specific name

%3CLINGO-SUB%20id%3D%22lingo-sub-243009%22%20slang%3D%22en-US%22%3EWeighted%20Average%20with%20multiple%20criteria%20and%20looking%20for%20specific%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-243009%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20I'm%20trying%20to%20figure%20out%20how%20to%20get%20the%20weighted%20average%20price%20of%20multiple%20products%20within%20the%20same%20class.%26nbsp%3B%20For%20example%20see%20the%20sheet%20below.%26nbsp%3B%20I%20want%20to%20find%20the%20weighted%20average%20price%20of%20all%20coke%20products%2C%20ie%20Coke%2FVanillaCoke%2FCherryCoke.%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20994px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F44998i60882DF00A3C910C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ExcelHelp.png%22%20title%3D%22ExcelHelp.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20formula%20I%20have%20tried%20is%3A%3C%2FP%3E%3CP%3E%3DSUMPRODUCT(--(LEFT(A%3AA%2C4)%3D%22Coke%22)%2C--(LEFT(A%3AA%2C4)%3D%22Vani%22)%2C--(LEFT(A%3AA%2C4)%3D%22cher%22)%2CB%3AB%2CC%3AC)%2FF2%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20doesn't%20work.%26nbsp%3B%20Please%20help!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-243009%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20Help%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-244161%22%20slang%3D%22en-US%22%3ERe%3A%20Weighted%20Average%20with%20multiple%20criteria%20and%20looking%20for%20specific%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-244161%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Blake%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20try%20this%20formula%3A%3C%2FP%3E%3CPRE%3E%3DAVERAGE(AVERAGEIFS(D2%3AD8%2C%20A2%3AA8%2C%7B%22Coke%22%2C%22VanillaCoke%22%2C%22CherryCoke%22%7D))%3C%2FPRE%3E%3CP%3EWith%20this%20formula%2C%20you%20don't%20have%20to%20manually%20calculate%20the%20Qty.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20the%20best%20way%20is%20to%20create%20another%20column%20in%20the%20table%20to%20hold%20the%20class%20for%20each%20product.%3C%2FP%3E%3CP%3EThis%20will%20make%20the%20calculation%20easier%20so%20that%20you%20don't%20have%20to%20hard-code%20each%20product%20in%20the%20formula.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20can%20be%20done%20as%20follows%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F45824i8C88BF9B49A7E979%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22AVERAGEIFS.png%22%20title%3D%22AVERAGEIFS.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20find%20the%20attached%20workbook%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2102515%22%20slang%3D%22en-US%22%3ERe%3A%20Weighted%20Average%20with%20multiple%20criteria%20and%20looking%20for%20specific%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2102515%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35679%22%20target%3D%22_blank%22%3E%40Haytham%20Amairah%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20example%2Fsolution%20is%20just%20the%20simple%20average%20and%20not%20the%20weighted%20average.%26nbsp%3B%20The%20calc%20for%20weighted%20average%20is%20as%20attached%20and%20would%20need%20a%20column%20with%20total%20cost%20per%20item%20calculated%20(cost%20per%20unit%20X%20units).%26nbsp%3B%20This%20column%20can%20then%20be%20hidden%20for%20presentation%20purposes%20if%20desired.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Deleted
Not applicable

Hi, I'm trying to figure out how to get the weighted average price of multiple products within the same class.  For example see the sheet below.  I want to find the weighted average price of all coke products, ie Coke/VanillaCoke/CherryCoke. 

ExcelHelp.png

 

The formula I have tried is:

=SUMPRODUCT(--(LEFT(A:A,4)="Coke"),--(LEFT(A:A,4)="Vani"),--(LEFT(A:A,4)="cher"),B:B,C:C)/F2

 

This doesn't work.  Please help!!

 

3 Replies
Best Response
Solution

Hi Blake,

 

Please try this formula:

=AVERAGE(AVERAGEIFS(D2:D8, A2:A8,{"Coke","VanillaCoke","CherryCoke"}))

With this formula, you don't have to manually calculate the Qty.

 

But the best way is to create another column in the table to hold the class for each product.

This will make the calculation easier so that you don't have to hard-code each product in the formula.

 

This can be done as follows:

AVERAGEIFS.png

 

 

Please find the attached workbook

Hope that helps

@Haytham Amairah 

 

This example/solution is just the simple average and not the weighted average.  The calc for weighted average is as attached and would need a column with total cost per item calculated (cost per unit X units).  This column can then be hidden for presentation purposes if desired.

With regards to your original formula, why not add a column to your table for product class (I think someone else may have suggested this already)? I would use a data validation drop down to make it easier and to avoid spelling errors. But, if you had product class in column A (I would not use the entire column as you'll likely get an error trying when sumproduct tries to multiply text - perhaps consider using a structured table):

 

=SUMPRODUCT(--(A2:A100=E2),B2:B100,C2:C100)/F2

 

And F2 is

=SUMPRODUCT(--(A2:A100=E2),B2:B100)

 

Also, you would add items that are OR conditions instead of multiplying (which is AND), but this is just for your information - I would suggest adding the product categories column.

 

=SUMPRODUCT((LEFT(A2:A100,4)="Coke")+(LEFT(A2:A100,4)="Vani")+(LEFT(A2:A100,4)="cher"),B2:B100,C2:C100)