+ Reply to Thread
Results 1 to 12 of 12

Read the top three items from a goods list

  1. #1
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Read the top three items from a goods list

    Hi

    Let's say you have a column that contains a random list of different types of veg. How would I list the top three items from the list in another 3 cells titled 1st, 2nd & 3rd?

    For example, let's say the column lists 5 apples, 3 bananas, 3 plums, 2 pears and a grapefruit. The "1st" cell should say "Apples", the "2nd" cell "Bananas" (tied with plums but sorted alphabetically) and the "3rd" cell "Pears". I can do the counts ok with COUNTIF but getting them in order is proving troublesome.

    thanks
    Andy
    Last edited by AndyGW; 11-28-2012 at 07:10 AM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,078

    Re: Read the top three items from a goods list

    Does this help?

    http://www.excelforum.com/excel-form...king-info.html
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Read the top three items from a goods list

    aha... pivot tables. I know nothing about these but I'll download that example and see how I get on before posting back.

  4. #4
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Read the top three items from a goods list

    I don't think a pivot table can help me here. Of course, I've only spent 30 mins trying so I may be missing something.

    I have just the 1 column of data and most of the tutorials show pivots working with multiple columns. I can populate the pivot table with the fields, eg Apples, Pears, Plums etc but I can't get it to count how often they appear, eg 5 Plums, 4 Apples etc,.

    COUNTIF will pull the number of each piece of veg but i want the top three names.

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Read the top three items from a goods list

    AndyGW,

    Attached is an example workbook based on the criteria you described.
    In sheet 'Data' is the list of Fruits in a random order.
    That information is used to create the pivot table shown on sheet 'Pivot Table'

    The pivot table is with:
    Row Label = Fruits
    Σ Values = Count of Fruits

    Then in sheet 'Pivot Table' I selected cell B2 (which is the first non-pivot table cell that is directly above the "Total" column) and went to Data -> Filter
    After that, I was able to use the Filter on Total to select "Number Filters" -> "Top 10..." -> changed from 10 to 3 -> OK

    The pivot table is now showing the top three count of fruits.
    Attached Files Attached Files
    Hope that helps,
    ~tigeravatar

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

  6. #6
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Read the top three items from a goods list

    Hi tigeravatar

    This is brilliant many thanks. It did exactly what I wanted. However, just as I thought it was too good to be true - it was! Nothing to do with your example, I since found out that pivot tables do not auto update along with the data when the sheet is calc'd (f9)

    So when I recalc the code that populates my column of data, the cells reading from the pivot table are wrong because it has not updated. When I manually update the pivot table I have to refresh the sheet again to get the cells to re-read the correct pivot table data, which in turn refreshes the original data column... arrgggghhh!!!!

    Unless there is a way to get the pivot table to refresh on f9 along with the data re-calc I'll have to find another way to do this.

    Repped for your help tho.

  7. #7
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Read the top three items from a goods list

    You should be able to right-click the pivot table and select "refresh"

  8. #8
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Read the top three items from a goods list

    I can but that doesnt solve the problem. Let me clarify. The pivot table reads the information contained in my data column. From that pivot table 3 other cells are populated with the 1st 2nd and 3rd highest appearances in the column. When I calc the sheet, the data column is populated but the pivot table does not update. Thus the 1st, 2nd & 3rd cells show old data. Sure I can update the pivot table but that doesn't make the 1st-3rd cells update, they still read wrongly. Only by hitting f9 do they update but then of course so does my data column and we're back to square one.
    Last edited by AndyGW; 11-27-2012 at 07:58 PM.

  9. #9
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Read the top three items from a goods list

    At this point I would need an example workbook to better understand what your requirements are so...

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.
    To attach a file, click the "Go Advanced" button and then click the paperclip icon to open the Manage Attachments dialog.

  10. #10
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Read the top three items from a goods list

    Ok. Ive made an example which shows exactly the problem im having.

    Sheet 1 has the goods column and sheet 2 the pivot table. As you will see when the fruit coulmn updates the 1st to 3rd count cells do not because they are reading from the non updated pivot table.

    I've put notes on sheet one too.
    Attached Files Attached Files

  11. #11
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: Read the top three items from a goods list

    A formula approach, see attachment.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Read the top three items from a goods list

    WHER - This is perfect, works like a dream. Thanks.

+ 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