I need to add a "Running Total" column in my Access Query. The purpose of this is to identify how many open locations there are at a given time.
There is a field called "Open Date" that I would like to be counted in Ascending Order.
In some instance, multiple locations open the same day as seen below:
╔══════════╦═══════════╦═══════════════╦
║ Location ║ Open Date ║ Running Total ║
╠══════════╬═══════════╬═══════════════╬
║ 1 ║ 1/1/1990 ║ 1 ║
║ 2 ║ 1/3/1990 ║ 2 ║
║ 5 ║ 1/3/1990 ║ 3 ║
║ 3 ║ 2/18/1991 ║ 4 ║
║ 6 ║ 3/17/1992 ║ 5 ║
║ 4 ║ 4/1/1995 ║ 6 ║
╚══════════╩═══════════╩═══════════════╩
So in this instance, I can say on 4/1/1995, there were 6 open locations.
I've tried using DSum and DCount, but neither of these give the result I wanted.
UPDATE:
Here is the code I am currently using:
SELECT t1.[store sort], t1.[soft opening],
(SELECT COUNT(t2.[store sort]) FROM [storelist query] as t2
WHERE Format(t2.[soft opening], "yyyy-mm-dd") & "-" & t2.[store sort] <=
Format(t1.[soft opening], "yyyy-mm-dd") & "-" & t1.[soft opening]) AS Running_Total
FROM [storelist query] as t1
ORDER BY Format(t1.[soft opening], "yyyy-mm-dd") & "-" & t1.[store sort];
However, here is the output:
+------------+--------------+---------------+
| store sort | soft opening | Running_Total |
+------------+--------------+---------------+
| 1 | 8/1/1980 | 1 |
| 10 | 4/1/1985 | 2 |
| 2 | 10/1/1986 | 2 |
| 3 | 4/1/1987 | 4 |
| 4 | 10/1/1987 | 4 |
| 5 | 3/1/1988 | 5 |
+------------+--------------+---------------+
Note: This is using the data. The previous example was just sample data I used for demonstration purposes.
As you can see, this isn't quite the desired effect.
In this instance, Store 2 should having a running total of 3 because it's the 3rd store. Store 4 should have a running total of 5 stores. And store 5 should having a running total of 6 stores, etc.