• Running Total in a Query (A97 SR-2)

    Author
    Topic
    #370454

    I am trying to calculate a running sum in a query as listed below.

    Amount RunningTotal
    1 1
    2 3
    3 6
    4 10

    I have tried using DSum as follows, but it results in the RunningTotal calculation being 10 in each row.

    RunningTotal: DSum(“[Amount]”,”tblData”)

    Viewing 0 reply threads
    Author
    Replies
    • #586232

      You need a unique key by which your data are ordered to do this.
      If your key field is named ID and the field you want to sum is Amount, the expression for Running Total would become

      DSum(“Amount”, “tblData”, “ID<=" & [ID])

      This means that DSum is taken over all records with an ID up to and including the ID in the current record.

      • #586259

        Thank you very much! I already had the ID field in the table and your solution worked great.

    Viewing 0 reply threads
    Reply To: Running Total in a Query (A97 SR-2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: