Results 1 to 3 of 3
  1. #1
    asawadude is offline Novice
    Windows 7 Access 2003
    Join Date
    Oct 2010
    Posts
    5

    Select query for running totals

    My Access skills are leaving a lot to be desired, and my self-taught skills are limited to the QBE screens.



    I could really use some guidance on how to create a simple query that generates a cumulative total. I have a simplified example of what I need in the attached screen capture.

    I have an Excel spreadsheet that performs the evaluation, but in the real world, my sample population contains approximately 800 prototypes with 12 different measurements evaluated. As a result, my spreadsheet is grossly unwieldy.

    If someone can help me get started based on the simplified info on the screen capture, it would be greatly appreciated. Thanks!

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I don't understand the [# needed] column, most of them are same with [# samples], but the last 3 are not. How did you calculate [# needed]?

    Here is a solution to get the total, but this is not a good solution because it runs very very slowly. Actually, Access query is not good at this kind of calculation. If you want speed it up, you need to write some VBA codes.

    select *, dsum("# samples","YOURTABLE","SCORE>="& SCORE) from YOURTABLE

  3. #3
    asawadude is offline Novice
    Windows 7 Access 2003
    Join Date
    Oct 2010
    Posts
    5
    Quote Originally Posted by weekend00 View Post
    I don't understand the [# needed] column, most of them are same with [# samples], but the last 3 are not. How did you calculate [# needed]?

    Here is a solution to get the total, but this is not a good solution because it runs very very slowly. Actually, Access query is not good at this kind of calculation. If you want speed it up, you need to write some VBA codes.

    select *, dsum("# samples","YOURTABLE","SCORE>="& SCORE) from YOURTABLE
    Thanks for the code, I'll give it a try.

    In my spreadsheet, the "# needed" column is used to find the cut-off point for 200 samples. In this case, I need 14 of 22 samples of prototype Viking to reach 200. The formula in Column F contains a nested multi IF-THEN-ELSE statements which evaluate Column E to see if the target (200) has been reached. If not, the prototype's samples count is added to the target total. It continues down the spreadsheet until it finds a value in Column E that equals or exceeds the target. In this case, the Viking sample contains the 200th highest scoring value can be found, however it's cumulative total is 208, 8 more samples then required.

    The IF-THEN-ELSE statement also contains the parameter that looks at the previous cumulative total to determine how many samples in the final group are required to reach the target. The formula looks at line 15 and sees that the Beta Sample cumulative total was 186. 200-186 is 14, so therefore only 14 samples of Viking are required to reach the target goal. The remaining samples are discarded...

    Because I looking for a defined number from the total population, this was the only way I could figure out how to do it. I need a more elegant solution than my spreadsheet which works fine, but is totally cumbersome.

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

Similar Threads

  1. Query - using Max Totals with Criteria
    By mslieder in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:02 AM
  2. Query Column Totals
    By lmp101010 in forum Queries
    Replies: 1
    Last Post: 08-06-2010, 01:03 PM
  3. Calculating Sub Totals in a Query
    By cassidym in forum Queries
    Replies: 2
    Last Post: 06-09-2010, 01:26 PM
  4. Adding Totals to a query using queryDef
    By jrickels in forum Programming
    Replies: 7
    Last Post: 04-06-2010, 07:47 AM
  5. query - totals
    By mslieder in forum Access
    Replies: 0
    Last Post: 02-22-2006, 06:11 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