Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Fuhgawz is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Location
    Johnson City, TN
    Posts
    8

    Multicalculated Query Help

    I have a table that has several rows of data.

    I want to be able to take column 5 and sum them into one number. Then take column 6 and sum them into a number. i then want to take the two sums and divides c6 int0 c5 and receive an overall percentage.

    Then I want to the overall percentage and divide it by the sum of c6 and store this result temporarily.

    Then i want to take the next whole number percentage and get the difference between the current overall percentage.



    Then i want to take this value and divide it out by the temporary value stored earlier and round this value up to the next whole number

    Example: SUMC6 / SumC5 = Overall percentage . This i can calculate and get 52.9 From here is where I have issues.

    I take 52.9 / 12359(SumC6) = .0042802 Then I I take 52.9 - 53 = .1 Then take .1 / .0042802 = 23.363394

    How can I get this data to return back in a query? Im sure I havent provided enough information let me know how else I can help get this solved.

    Thank you in advance.
    Attached Files Attached Files
    Last edited by Fuhgawz; 06-15-2015 at 03:34 PM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    This would likely involve several queries.

    Possibly a report would provide the output you want. Use report Sorting & Grouping features with aggregate calcs in footer sections.
    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.

  3. #3
    Fuhgawz is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Location
    Johnson City, TN
    Posts
    8
    Would having these queries update the results into a new table; then creating a macro to run these queries to run them work? Then running a query from the new table to retrieve the data work as well?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why would you want to save results into a table? Doing that will require DELETE and INSERT SQL actions and/or code (macro or VBA) to automate.
    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.

  5. #5
    Fuhgawz is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Location
    Johnson City, TN
    Posts
    8
    ok then this would go back to my original question if this is going to take multiple queries then how would I reference back to other results needed to return the information that I am looking to retireve?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Queries, like tables, can be used in queries.

    Queries can be nested (subqueries). Review: http://allenbrowne.com/subquery-01.html
    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.

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    What are you going to do with the result? Just display it so you can see the result?

    Using queries, it would take 2 queries: the first query, a totals query, based on the table.
    the second query, based on the totals query, to do the calculations.

    Another option is to write a UDF (VBA). This would involve a record set (a totals query) to get the sums of the two fields, then do the calculations.
    I prefer the UDF because I can control what happens a lot easier.

  8. #8
    Fuhgawz is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Location
    Johnson City, TN
    Posts
    8
    I have zipped up my table and added to the original post.

    What i am looking to do is to add onto the first query or create a new query and calculate by Console what my current completion rate is and how achievements i need to earn (by console) to increase my completion percentage. As i mentioned in the OP the math posted there but as far as applying it to a SQL statement to retireve it/update it as I continue to update my table i am at a loss.

    This is just a personal project for me as I wanted to track my own gaming data for my consoles.

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The two fields you want to use in the calculations are:TtlAch & AchEarned ??

    You have their field type as Text. They should be Number/Single, if (since) you are doing math on them.

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You described how to do the math using C5 & C6.
    Please explain again, but using actual field names.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You already have a report started based on aggregate query. Remove the GroupBy on OverallComplete field.

    Could probably base report on the raw table data and do the calcs you describe on the report. Set up grouping on the report and do aggregate calcs in group and report footer sections.
    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.

  12. #12
    Fuhgawz is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Location
    Johnson City, TN
    Posts
    8
    Quote Originally Posted by ssanfu View Post
    You described how to do the math using C5 & C6.
    Please explain again, but using actual field names.
    c5= TtlAch , c6, AchEarned

    I correct both fields to numbers now.

  13. #13
    Fuhgawz is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Location
    Johnson City, TN
    Posts
    8
    Quote Originally Posted by June7 View Post
    You already have a report started based on aggregate query. Remove the GroupBy on OverallComplete field.

    Could probably base report on the raw table data and do the calcs you describe on the report. Set up grouping on the report and do aggregate calcs in group and report footer sections.
    The report I have was just me tinkering around. I have little knowledge about access honestly.

  14. #14
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Basically, this is what I did:
    Step 1: OverallPercentage =SumOfAchEarned / SumOfTtlAch

    Step 2: Result1 =OverallPercentage / SumOfAchEarned

    Step 3 NextInt = Int(OverallPercentage +1)

    Step 4: Result2 = OverallPercentage - NextInt (and change sign)

    Step 5 GameCompletionPct = Result2 / Result1

    In the query, there is rounding performed to match your numbers.


    See if this is what you are looking for:

  15. #15
    Fuhgawz is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Location
    Johnson City, TN
    Posts
    8
    Quote Originally Posted by ssanfu View Post
    Basically, this is what I did:
    Step 1: OverallPercentage =SumOfAchEarned / SumOfTtlAch

    Step 2: Result1 =OverallPercentage / SumOfAchEarned

    Step 3 NextInt = Int(OverallPercentage +1)

    Step 4: Result2 = OverallPercentage - NextInt (and change sign)

    Step 5 GameCompletionPct = Result2 / Result1

    In the query, there is rounding performed to match your numbers.


    See if this is what you are looking for:

    Thanks this was nearly what I was looking for. I made some slight modifications to capture exactly what I was looking for. However in Step 2 I have one issue that I cannot figure out how to resolve. If the NextInt > 100 then it should result in 100. everything else it should return the actual value. I'm sure this is an IF statement but I cannot get it to work correctly.

    Also the reports were working fine when I first check them but now appear to not be working probably where I made changes to the Steps.

    I attached the file below again if you or someone else can give a hand with the last issue I am having.

    GameCompletion.zip

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

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