Results 1 to 5 of 5
  1. #1
    maliotta is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2014
    Posts
    2

    Calculating Percentiles in Access

    Hi,



    I need some help.

    I have two columns.

    Column A (Codes) has all of the products I'm analyzing.
    There can be anywhere from 100s to 1000s of lines (rows) for each specific product in Column A.
    There are 100s of different products. So there's like 300,000 lines of data.

    Column B has all of the prices for each product in Column A. (Prices can vary for the same product.)
    I'm trying to find the price differences using Percentiles (25% percentile price, 75% percentile price, etc.).

    In Excel, I tried to get the output in Column C for the 25th percentile using the following formula:

    =PERCENTILE(IF($B$2:$B414489=$B2,$C$2:$C$414489,"" ),0.25)

    It won't work because it's too much data.


    I have these two columns in Microsoft Access in the same order.
    How can calculate the percentiles for the 25th, 50th, and 75th in 3 columns to the right?




    Please help me!
    I can't figure this out!


    Thanks.


    P.S. I'm new to Access. I need all steps.
    Last edited by pbaldy; 03-13-2014 at 11:23 AM. Reason: removed links

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Can you post some data?

    From FMS site:

    How Percentiles are Calculated

    Percentiles are calculated by sorting the data from smallest to largest. The middle value is the median (50th percentile). Dividing into 4 groups gives quartiles (25th, 50th, and 75th percentiles), and 10 groups give deciles. This is the formula used to determine which record is selected for any percentile value:

    where N is the number of items, and Percentile is a number between 0 and 100. For instance, for a sample size of 13, the quartile records for the 25th, 50th, and 75th percentiles are 4, 7, 11. By definition, the 0th and 100th percentiles are the lowest and highest values.
    If the percentile cut-offs do not coincide with a particular data point, a linear interpolation of the two closest points is used. If a weighting field is assigned, values are considered continuous and no interpolation is performed.


    If you put your values into ascending sequence, you should be able to get the X percentile from

    Code:
    SELECT Max([Id]) AS MyPercentile
    FROM (SELECT TOP 93 PERCENT [id] FROM tblPercentileTest ORDER BY [id])  AS [malias];
    Substitute the percentile you want for the 93 in my example. Adjust your field names as needed.

  3. #3
    maliotta is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2014
    Posts
    2
    Thanks for the reply.

    The issue is that the Code must differentiate between products in the 1st Column. The 2nd Column contain the prices associated with the products in the 1st Column. For instance:

    Column 1--Column 2
    A---------$1.01
    A---------$1.43
    A---------$1.30
    A---------$1.50
    B--------$300.43
    B--------$295.43
    B--------$287.35
    B--------$305.78
    C---------$89.23
    C---------$85.68
    C---------$86.43
    C---------$91.45
    C---------$80.56


    Above is an extremely simplified version of what I'm dealing with.
    I have 400,000 lines for Column 1 and Column 2. There are 100 of different products with thousands of associated prices in Column 2.

    So, I need the code to understand this and pick it up. My array formula that I posted does this. Excel just is not strong enough to calculate percentiles in this way -- even with only 5,000 lines of data with 50 products and associated prices.


    Can your Code do this?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Can you show an example of what you expect as output using say one of the products in your sample?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,648
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculating Age
    By Koyangie in forum Queries
    Replies: 2
    Last Post: 04-05-2012, 03:11 PM
  2. Calculating Age from DOB
    By coolpal9 in forum Forms
    Replies: 15
    Last Post: 01-12-2012, 05:26 AM
  3. Replies: 4
    Last Post: 12-16-2010, 05:29 AM
  4. calculating due dates in access
    By trixxnixon in forum Forms
    Replies: 0
    Last Post: 09-28-2008, 12:35 PM
  5. Replies: 0
    Last Post: 09-25-2008, 12:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums