+ Reply to Thread
Results 1 to 8 of 8

Weighted average w/ multiple text criteria excel 2010

  1. #1
    Registered User
    Join Date
    07-30-2013
    Location
    binningen
    MS-Off Ver
    Excel 2010
    Posts
    28

    Weighted average w/ multiple text criteria excel 2010

    hi

    i'm looking to get a weighted average from a table (in 'database format') for specific rows. i'm working on excel 2010.
    below might help to convey the idea of what i am trying to achieve, although the actual solution will probably differ considerably.

    to illustrate my problem better, below some sample data:

    (desk) (type) (commodity) (MT) (cost$) (MTM$)
    paris positions corn 1000 $300 $250
    paris positionsl wheat 2000 $280 $300
    london futures corn -3000 $290 $250
    london options wheat -2000 $280 $230
    paris futures corn 5000 $280 $250

    i need the weighted average cost$ and marked-to-market (MTM$) for each desk and commodity, i.e. weighted average cost$ for corn in paris --> (1000x$300+5000x$250/6000)

    this is my formula so far, which returns a DIV/0 error:
    =SUMPRODUCT((Table1[Type]="Positions")*(Table1[Type]="Futures")*(Table1[Type]="Options")*(Table1[Desk]='Grain Positions'!$A$3)*(Table1[Commodity]='Grain Positions'!A4);ABS(Table1[MT]);Table1[USD /MT (Cost)])/SUMPRODUCT((Table1[Type]="Positions")*(Table1[Type]="Futures")*(Table1[Type]="Options")*(Table1[Desk]='Grain Positions'!$A$3)*(Table1[Commodity]='Grain Positions'!A4);ABS(Table1[MT]))

    thanks for your help!
    Last edited by mischge; 07-30-2013 at 03:52 AM.

  2. #2
    Forum Contributor
    Join Date
    04-13-2010
    Location
    England
    MS-Off Ver
    Office 2016 365
    Posts
    211

    Re: Weighted average w/ multiple text criteria excel 2010

    Alright mate,

    See file attached. Can you add a helper column? If you can then add a total for MMT and cost then you can also add a Key by concatenating the Product and the Location...then SUMIF does the rest!
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-30-2013
    Location
    binningen
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Weighted average w/ multiple text criteria excel 2010

    hi JungleJme

    thanks for your file.

    i've always tried to solve this problem using a SUMPRODUCT function, in order to avoid having to add more columns.

    i've attached your sheet again with 1 modification, where the table now also contains 'receivables', which are not to be included in the average. you'll also find my formula as i have it, albeit it does not work, for reasons escaping me...

    looking forward to seeing your ideas! thanks a lot!

    Exa mple 2.xlsx

  4. #4
    Forum Contributor
    Join Date
    04-13-2010
    Location
    England
    MS-Off Ver
    Office 2016 365
    Posts
    211

    Re: Weighted average w/ multiple text criteria excel 2010

    OK, if you don't want to use helper columns then see the attached!

    Adding -- in front of the clauses where you are setting a condition turns the results of those clauses from Boolean (true/false) into numbers, this allows sumproduct to multiply up each line that passes the conditions
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-30-2013
    Location
    binningen
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Weighted average w/ multiple text criteria excel 2010

    hardcore! works like a charm!
    only change to the formula to achieve a weighted average is to put ABS(Table1[MT]), otherwise your short positions (negative tonnage) will mess up the calc.

    thanks a lot JungleJme!!

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Weighted average w/ multiple text criteria excel 2010

    You can simplify both formulae by using selecting the whole table, and define names by Create From Selection. The formulae then become:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    And

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  7. #7
    Registered User
    Join Date
    07-30-2013
    Location
    binningen
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Weighted average w/ multiple text criteria excel 2010

    thanks newdoverman, believe that's just what JungleJme did in his second attachment.

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Weighted average w/ multiple text criteria excel 2010

    The formulae are the same but without the difficult to read "Table syntax" that some may find difficult to understand.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Weighted Average with Criteria
    By Leopold2000 in forum Excel General
    Replies: 7
    Last Post: 06-06-2018, 12:24 AM
  2. [SOLVED] Calculate a weighted average in a single cell based on multiple criteria
    By _Bryan in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-14-2013, 04:38 PM
  3. Weighted Average with 2 Criteria
    By Leopold2000 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-11-2013, 04:49 PM
  4. Weighted Average with criteria
    By Larko in forum Excel General
    Replies: 2
    Last Post: 11-10-2010, 12:03 PM
  5. Weighted average with criteria
    By TheGame0135 in forum Excel General
    Replies: 11
    Last Post: 07-01-2010, 01:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1