+ Reply to Thread
Results 1 to 5 of 5

Multiple occurrence => 1 occurrence

  1. #1
    Registered User
    Join Date
    09-07-2010
    Location
    Casablanca
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    2

    Multiple occurrence => 1 occurrence

    Hi,

    I have an excel file with 2 columns (product, price)

    In this file I have multiple occurrence of products :


    Please Login or Register  to view this content.

    I have two occurrences of beer, I want to have only one with the price being the average of the two.


    Please Login or Register  to view this content.

    Thanks
    Last edited by NBVC; 09-08-2010 at 07:47 AM.

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

    Re: Multiple occurrence => 1 occurrence

    You can use a Pivot table to list the unique items and their respective averages.

    A quick start guide....

    http://peltiertech.com/Excel/Pivots/pivotstart.htm
    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 Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Multiple occurrence => 1 occurrence

    Create a unique list of your products, then use Averageif() to calculate the average.

    To create a unique list, you can select the Product column, then go Data - Filter - Advanced Filter, tick "unique items only" and specify to filter to a new location, select a cell for the new list.

    Say your new list with unique products now is in column D, and your original data is in columns A and B. You can now use AverageIf starting in row one of a cell

    =averageif($A$1:$A$100,D1,$B$1:$B$100)

    copy down.

    cheers

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Multiple occurrence => 1 occurrence

    If as implied by your profile you are running XL2003 you can replace AVERAGEIF with a SUMIF/COUNTIF construct (AVERAGEIF introduced in XL2007)

    That said - a Pivot does seem perfect...

  5. #5
    Registered User
    Join Date
    09-07-2010
    Location
    Casablanca
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    2

    Re: Multiple occurrence => 1 occurrence

    Quote Originally Posted by NBVC View Post
    You can use a Pivot table to list the unique items and their respective averages.

    A quick start guide....

    http://peltiertech.com/Excel/Pivots/pivotstart.htm
    Exactly what I was looking for : A SELECT AVG GROUP BY like.

    Thanks


    Quote Originally Posted by teylyn View Post
    Create a unique list of your products, then use Averageif() to calculate the average.

    ....
    cheers
    Lazy me prefers the Pivot table, but thanks for your help.


    Quote Originally Posted by DonkeyOte View Post
    If as implied by your profile you are running XL2003 you can replace AVERAGEIF with a SUMIF/COUNTIF construct (AVERAGEIF introduced in XL2007)

    That said - a Pivot does seem perfect...
    I fixed my profile
    Last edited by exhortae; 09-08-2010 at 05:02 AM.

+ 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