+ Reply to Thread
Results 1 to 8 of 8

Dynamically Extract Top "N" values from Database

  1. #1
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256

    Dynamically Extract Top "N" values from Database

    Hi,

    Currently working on the case to extract Product codes based on, for example, Top 10 values from the database, for which I use current formula:

    Please Login or Register  to view this content.
    However it has a limitation, it works only for Unquiet list, in other words list of products should be unique and the values should be SUMMED.


    Is it possible to include in formula, or use other formula combination which will work in database with non-unique values? In other words formula should indicate distinct products sum up their respective values and then list top products.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,434

    Re: Dynamically Extract Top "N" values from Database

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Dynamically Extract Top "N" values from Database

    When you post a formula with named ranges it gives us less to work with, we can't see if the range is absolute, relative or dynamic.

    From what I make out from your formula, a helper column adjacent to the range 'Figures'. Assuming that the range 'Figures' refers to $B$2:$B$100 (adjust ranges as necessary) enter this into C2 and fill down

    =COUNTIF(B$2:B$100,">"&B2)+COUNTIF(B$2:$B2,B2)

    Then get your top 10 list by using

    =INDEX(List,MATCH(ROWS($G$2:$G2),$C$2:$C$100,0))

    Fill down as needed.

    edit:- just re-read your question and think I might have misread part of it.
    Last edited by jason.b75; 08-15-2018 at 05:23 AM.

  4. #4
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256

    Re: Dynamically Extract Top "N" values from Database

    Hi,

    Thanks for the reply.

    Please see attached sample file with sample data, result and current usage of formula
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Dynamically Extract Top "N" values from Database

    Is a pivot table an acceptable solution? It just took me 10 seconds to get your required results using one.

  6. #6
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Dynamically Extract Top "N" values from Database

    Hi

    Consider a 'DATA' table with product and quantity, a Table 'List_of_Products' as a list of unique names of products.

    A Top_table can be created using the following array formula:

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

    I think you'd be better off using a PivotTable to summarize your data table.

    See the sample file
    Attached Files Attached Files

  7. #7
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256

    Re: Dynamically Extract Top "N" values from Database

    Your formula works partially, it can be achieved via the formula I posted in the beginning, but it gives result, based on the max value of duplicate values, what we need is to sum up values of duplicate values and then make a list.

    We can get result via Pivot table, but I chose formula so to make the result dynamic.

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Dynamically Extract Top "N" values from Database

    Setting the source as a data table will make it dynamic. Then use a worksheet change event to force refreshing if required.

+ 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. Replies: 0
    Last Post: 01-09-2013, 06:52 PM
  2. Macro to extract data into different tabs for each values in column D "Group"
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-26-2012, 03:30 PM
  3. Replies: 1
    Last Post: 10-22-2012, 09:38 AM
  4. Replies: 3
    Last Post: 02-16-2011, 02:55 PM
  5. Replies: 6
    Last Post: 08-11-2009, 07:22 AM
  6. Extract all matching rows with "Active" from a database
    By smalldoll in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-23-2009, 10:00 AM
  7. Replies: 5
    Last Post: 09-19-2008, 04:02 PM
  8. Replies: 6
    Last Post: 11-01-2007, 11:56 AM

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