Creating a Running Total for Each Record (1 Viewer)

FinanceGuy

New member
Local time
Yesterday, 23:28
Joined
May 7, 2021
Messages
5
With the four columns on the left down below, I want to be able to populate the fifth column (Year to Date Revenue):

SubscriberMonthYearMonthly RevenueYear to Date Revenue
Apple12020$100$100
Apple22020$300$400
Apple122020$1,250$1,250
Pepsi12020$200$200
Pepsi22020$500$700
Apple32021$100$100
Apple42021$400$500
Pepsi12021$600$600
Pepsi22021$1000$1,600

What is the best function or query to get the Year to Date Revenue column populated?

I've been experimenting with DSum, but cannot seem to get it to work. I am open to creating a temporary table to calculate and get the fifth column and joining that table and appending the data from that column into my master table.
 

conception_native_0123

Well-known member
Local time
Yesterday, 22:28
Joined
Mar 13, 2021
Messages
1,834
does the query in this sample give you an idea of what you can do to get it done?
 

Attachments

  • Running Balance.zip
    30.3 KB · Views: 513

Isaac

Lifelong Learner
Local time
Yesterday, 20:28
Joined
Mar 14, 2017
Messages
8,777
Dear Mr Gates, when you are done settling your ... personal business ... and have time for Access again, please give us Windowing.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 04:28
Joined
Feb 19, 2013
Messages
16,605
in a query Join the table to itself on subscriber, alias one as A and the other as B.

bring down the fields from A and the monthly revenue from B

it is unfortunate you have month and year as separate values since this makes the next bit more complicated as you have to combine then to create a sortable order.

The calculation you need is (yearx100) + month. It is also unfortunate that both month and year are reserved words and should not be used as field names so you will need to enclose these in square brackets,

So the criteria you need is where the A calculated value is >= to the B calculated value.

now convert your query to an aggregate query (group by)

group on the A fields and sum the B field

you can also sort on the A subscriber and calculated value to get the right order. If this is for a report you will need to bring the A.calculated value through because sorting is done in the report - query sorts will be ignored
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:28
Joined
May 7, 2009
Messages
19,230
ytd, for each year.
 

Attachments

  • yearToDateBalance.accdb
    440 KB · Views: 531

conception_native_0123

Well-known member
Local time
Yesterday, 22:28
Joined
Mar 13, 2021
Messages
1,834
Dear Mr Gates, when you are done settling your ... personal business ... and have time for Access again, please give us Windowing.
good luck with that! don't forget to address his earthly-covered bunker that he sleeps in over there in washington state!
 

Users who are viewing this thread

Top Bottom