+ Reply to Thread
Results 1 to 6 of 6

Calculate an average using multiple criteria on 2 worksheets

  1. #1
    Registered User
    Join Date
    06-15-2010
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2003
    Posts
    2

    Calculate an average using multiple criteria on 2 worksheets

    Hi,

    I am making a spreadsheet to track fuel costs from 3 vendors, and I want to calculate the average price per litre for each vendor, for each month.

    I have 2 worksheets: (1) Data Entry, and (2) AVG PPL

    Data will be entered in the Data Entry worksheet as follows:

    Column A: Vendor name
    Column B: Period (i.e.: Sept. 2010)
    Column C: The price per litre.

    I want to calculate the average price per litre on the "AVG PPL" worksheet based on the data inputted into the "Data Entry" worksheet.

    For example: in cell B2 in the "AVG PPL" worksheet I want to calculate the average price per litre for all entries in the "Data Entry" worksheet that match Vendor A, and the period Sept. 2009.

    My problem is that I don't know what formula to use in cell B2 to calculate this average. I thought it would look something like this:

    =average(if(and('Data Entry'!$A$A="Vendor A",'Data Entry'!$B$B="Sept 2009")'Data Entry'!$C$C))

    but this doesn't work.

    A copy of the spreadsheet is attached.

    Please help.

    Thanks
    Attached Files Attached Files
    Last edited by Maddyx00x; 06-15-2010 at 01:17 PM. Reason: Solved

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: How to calculate an average using multiple criteria on 2 worksheets

    How about a quick and easy Pivot table...
    Attached Files Attached Files
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,578

    Re: How to calculate an average using multiple criteria on 2 worksheets

    Or this much more complex formula in B2 which can be dragged across and down;
    =IF(SUMPRODUCT(--('Data Entry'!$A$2:$A$1000=$A2),--('Data Entry'!$B$2:$B$1000=B$1))=0,0,SUMPRODUCT(--('Data Entry'!$A$2:$A$1000=$A2),--('Data Entry'!$B$2:$B$1000=B$1),'Data Entry'!$C$2:$C$1000)/SUMPRODUCT(--('Data Entry'!$A$2:$A$1000=$A2),--('Data Entry'!$B$2:$B$1000=B$1)))
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    06-15-2010
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Calculate an average using multiple criteria on 2 worksheets

    It works!

    Thanks ChemistB. That is indeed a complex formula.

    I'm not familar with pivot tables, but I will search this forum for tutorials. Thanks NBVC.

  5. #5
    Registered User
    Join Date
    06-27-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Calculate an average using multiple criteria on 2 worksheets

    Hi Guys, I am following this topic and am comparing the results from the pivot table and the formula which are different!

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,578

    Re: Calculate an average using multiple criteria on 2 worksheets

    Hi Alm,
    Just double checked and the values do match up on the example given. See attached. Pivot Table is definitely the way to go, however.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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