Results 1 to 9 of 9
  1. #1
    kwooten is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    255

    Question Running Total Query??


    I am trying to rebuild a query I crashed yesterday. While doing some research in an effort to make it better I am looking for some help. The goal is to create a month to month "running total" rate. In the past I made 2 seperate crosstab queries so i would have my individual date data, then I would create a sum function to sum each month. However, what I would like to do is show month to month growth in the rate.

    The formula for the rate is Total X/Average Y. I did some research and thought a DSum may be the answer; at least for the Total X. Not sure how to incorporate the Average Y.

    So for January 2012 I would have, for example, 5% with a formula of 10/200.. February 2012 raw data may be X=15 and Y=100 so for February 2012 I would need my formula to be 25 (Total of X; 10 and 15) /150 (Average of Y; 200 and 100)..

    Any Ideas?

  2. #2
    kwooten is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    255
    Just figured out DSum doesnt work well for Total X but DCount seems to.

  3. #3
    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,849
    Can you lay out an example that shows both your X and Y?
    Can you give X and Y the actual names and some of the real values in order to clarify what
    a month to month "running total" rate really means in your situation?

  4. #4
    kwooten is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    255
    I got the DCount figured out for X and I have the average for Y... Im gonna try another method to run the rates. Running Total month to month rate would show growth so January may be 5% then add in for February and the percent may increase to 7% and so on...

  5. #5
    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,849
    I'm not sure what you're doing but I did create the routine below to try a few things. It may be useful but as I say, I'm not clear on what you really are trying to do.

    Code:
    Sub testRunningAvg()
    Dim Tot As Integer
    Dim i As Integer
    Dim x As Integer
    x = 100
    Tot = 0
    Dim Pct As Double
    Dim M(11) As Integer
    M(0) = 30
    M(1) = 20
    M(2) = 10
    M(3) = 25
    M(4) = 35
    M(5) = 50
    M(6) = 10
    M(7) = 35
    M(8) = 40
    M(9) = 25
    M(10) = 15
    M(11) = 90
    
    For i = 0 To 11
    ' Tot is the total of the M(i)s up to this value of i
    'TotPct is the Number of (i *100) + 100 (to make up for the initial 0 address)
    Tot = Tot + M(i)
    Debug.Print "i  " & i & "  M(i)  " & M(i) & "  Pct  " & (M(i) / 100) * 100 & " Running Numbers  " & Tot & "  Tot Pct  " & x + (100 * i) & "  Tot/TotPct = " & Tot / (x + (100 * i)) * 100
    Next i
    End Sub

  6. #6
    kwooten is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    255
    attached is the running total peice.. when i add in the DIV1 code it doesnt give me the running total per code.. it gives me the same total for every code.

    Thanks,
    Attached Files Attached Files

  7. #7
    kwooten is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    255
    On this same DB can you do a running average? I cant get it to work. I think i have to incorporate a count first. I am trying to do the average of the empno.

  8. #8
    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,849
    Did you run the procedure I posted?Any comments?

    I just looked at your mdb. Where does "turnover" come from?
    I don't see Running Totals , Rates...Average..

  9. #9
    kwooten is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    255
    not yet.. i got pulled into something else.

    For some reason this DB isnt showing all the Objects. I have to tell it to show all object. Turnover comes from the Terms Tbl. The turnover qry does have the running totals. I cant get to the rate yet because I cant seem to get the running turnover by DIV 1 to work and I cant get a running average to work either. If i could get those 2 pieces then the rest is easy. Im running out of ideas beyond take the raw data and dumping it into excel which is not what i want to do.

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

Similar Threads

  1. running or sub total using sql query in access
    By learning_graccess in forum Access
    Replies: 4
    Last Post: 10-15-2011, 05:40 AM
  2. Running total
    By lololthis in forum Queries
    Replies: 5
    Last Post: 06-21-2011, 04:14 PM
  3. Using running total in query to create graphs
    By maggioant in forum Queries
    Replies: 4
    Last Post: 10-02-2009, 05:58 AM
  4. Replies: 2
    Last Post: 09-30-2009, 09:40 AM
  5. Creating a Daily Running Total Query
    By seraph in forum Queries
    Replies: 0
    Last Post: 08-15-2009, 12:11 AM

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