Cuummulative Totals By Month (1 Viewer)

cabber

New member
Local time
Today, 23:21
Joined
Apr 19, 2020
Messages
7
I would like to create a query that will add the previous months figure as a cummulative total per month ie
Jan 2250
Feb 3000 This would be 5250
March 2000 This would be 7250
and so on

Any help greatly appriciated

Thank
 

Ranman256

Well-known member
Local time
Today, 18:21
Joined
Apr 9, 2015
Messages
4,339
you can do it easily in a report.
set the query to the report, add another text box for Amt (this will be the running total amt)
set property to RUNNING SUM =OVER ALL, (or over group)
easy.

not so with query alone.
 

plog

Banishment Pending
Local time
Today, 17:21
Joined
May 11, 2011
Messages
11,638
Can you post sample data from the table this will be built on? Include table and field names and enough data to cover all cases.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:21
Joined
May 7, 2009
Messages
19,229
replace the tablename, fieldnames in this query with the
name of table,field you have:
Code:
SELECT
    Format([dateField],"mmm yyyy") AS MonthYear,
    DSum("amountField","yourTableName",
        "Format(datefield,'yyyymm') <= '" & Format([dateField],"yyyymm") &
        "' And Year(dateField)=" & Year([dateField])) AS RunningTotal
FROM yourTableName
GROUP BY
    Format([dateField],"mmm yyyy"),
    DSum("amountField","yourTableName","Format(datefield,'yyyymm') <= '" & Format([dateField],"yyyymm") &
    "' And Year(dateField)=" & Year([dateField])), Format([datefield],"yyyymm")
ORDER BY Format([datefield],"yyyymm");
 

cabber

New member
Local time
Today, 23:21
Joined
Apr 19, 2020
Messages
7
After a few errors, managed to get it working

Thanks
 

Users who are viewing this thread

Top Bottom