473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

create a running subtotal in a query and then graph results

Hello,
I am trying to create a running subtotal in a query and then graph the
running subtotal for each city group. The data looks like this in the
table (for illustration):

My City My Date Cumulative Sum Daily Sum
DC 03-Apr-07 6 6
DC 04-Apr-07 20 14
DC 05-Apr-07 0 0
DC 06-Apr-07 24 4
DC 09-Apr-07 26 2
DC 10-Apr-07 0 6
DC 11-Apr-07 32 44
Arlington 12-Apr-07 2 2
Arlington 13-Apr-07 0 0
Arlington 16-Apr-07 3 1
Arlington 17-Apr-07 0 0

The problem is that the cumulative sum goes to zero when the daily sum
is 0, so the graph is not cumulative. I need the cumulative sum to
never be 0, unless all previous values for the group are zero.

I was able to use DSum() to calculate a running sum, but it was over
the entire record set, not by city, so that did not work. I know a
report will work for this, too, but I need a query so I can graph the
values.

Any help is greatly appreciated! I thought this would be trivial, but
I cannot figure out how to do it.

Best,
Meb

Apr 20 '07 #1
5 3953
me*******@yahoo.com wrote:
Hello,
I am trying to create a running subtotal in a query and then graph the
running subtotal for each city group. The data looks like this in the
table (for illustration):

My City My Date Cumulative Sum Daily Sum
DC 03-Apr-07 6 6
DC 04-Apr-07 20 14
DC 05-Apr-07 0 0
DC 06-Apr-07 24 4
DC 09-Apr-07 26 2
DC 10-Apr-07 0 6
DC 11-Apr-07 32 44
Arlington 12-Apr-07 2 2
Arlington 13-Apr-07 0 0
Arlington 16-Apr-07 3 1
Arlington 17-Apr-07 0 0

The problem is that the cumulative sum goes to zero when the daily sum
is 0, so the graph is not cumulative. I need the cumulative sum to
never be 0, unless all previous values for the group are zero.

I was able to use DSum() to calculate a running sum, but it was over
the entire record set, not by city, so that did not work. I know a
report will work for this, too, but I need a query so I can graph the
values.

Any help is greatly appreciated! I thought this would be trivial, but
I cannot figure out how to do it.

Best,
Meb
You aren't using Dsum correctly.
Cumulative Sum: Dsum("[Daily Sum]","TableName",
"City = '" & [My City] & "' And "
"My Date <= #" & [My Date])
Apr 20 '07 #2
salad wrote:
me*******@yahoo.com wrote:
>Hello,
I am trying to create a running subtotal in a query and then graph the
running subtotal for each city group. The data looks like this in the
table (for illustration):

My City My Date Cumulative Sum Daily Sum
DC 03-Apr-07 6 6
DC 04-Apr-07 20 14
DC 05-Apr-07 0 0
DC 06-Apr-07 24 4
DC 09-Apr-07 26 2
DC 10-Apr-07 0 6
DC 11-Apr-07 32 44
Arlington 12-Apr-07 2 2
Arlington 13-Apr-07 0 0
Arlington 16-Apr-07 3 1
Arlington 17-Apr-07 0 0

The problem is that the cumulative sum goes to zero when the daily sum
is 0, so the graph is not cumulative. I need the cumulative sum to
never be 0, unless all previous values for the group are zero.

I was able to use DSum() to calculate a running sum, but it was over
the entire record set, not by city, so that did not work. I know a
report will work for this, too, but I need a query so I can graph the
values.

Any help is greatly appreciated! I thought this would be trivial, but
I cannot figure out how to do it.

Best,
Meb
You aren't using Dsum correctly.
Cumulative Sum: Dsum("[Daily Sum]","TableName",
"City = '" & [My City] & "' And "
"My Date <= #" & [My Date])
That shoud be
"My Date <= #" & [My Date] & "#")
Apr 20 '07 #3
On Apr 20, 11:28 am, salad <o...@vinegar.comwrote:
salad wrote:
mebrab...@yahoo.com wrote:
Hello,
I am trying to create a running subtotal in a query and then graph the
running subtotal for each city group. The data looks like this in the
table (for illustration):
My City My Date Cumulative Sum Daily Sum
DC 03-Apr-07 6 6
DC 04-Apr-07 20 14
DC 05-Apr-07 0 0
DC 06-Apr-07 24 4
DC 09-Apr-07 26 2
DC 10-Apr-07 0 6
DC 11-Apr-07 32 44
Arlington 12-Apr-07 2 2
Arlington 13-Apr-07 0 0
Arlington 16-Apr-07 3 1
Arlington 17-Apr-07 0 0
The problem is that the cumulative sum goes to zero when the daily sum
is 0, so the graph is not cumulative. I need the cumulative sum to
never be 0, unless all previous values for the group are zero.
I was able to use DSum() to calculate a running sum, but it was over
the entire record set, not by city, so that did not work. I know a
report will work for this, too, but I need a query so I can graph the
values.
Any help is greatly appreciated! I thought this would be trivial, but
I cannot figure out how to do it.
Best,
Meb
You aren't using Dsum correctly.
Cumulative Sum: Dsum("[Daily Sum]","TableName",
"City = '" & [My City] & "' And "
"My Date <= #" & [My Date])

That shoud be
"My Date <= #" & [My Date] & "#")- Hide quoted text -

- Show quoted text -
Thanks for the direction. Am just learning that it matters for the
syntax whether the field is numeric or character string. I am still
using incorrect criteria. It looks like the critieria are just being
ignored, based on the response I am getting. This is what I have (it
returns just one value which is the total for all rows, rather than a
running subtotal for each [MyCity] group). I am unclear on whether or
not I need the first criteria (on MyPK), which is on a primary key
value that is unique and sequential for each row? I have tried
without this part of the criteria and get the same result.

Also unclear on whether date should be <= or >=? The dates are
arranged in ascending order, by [MyCity].

MySum: DSum("MySum","mytablename","[MyPK] <=" & [MyPK] And "[MyCity] =
'" & [MyCity] & "'" And "[MyDate] <= #" & [MyDate] & "#")

Thanks for the help,
meb

Apr 20 '07 #4
me*******@yahoo.com wrote:
On Apr 20, 11:28 am, salad <o...@vinegar.comwrote:
>>salad wrote:
>>>mebrab...@yahoo.com wrote:
>>>>Hello,
I am trying to create a running subtotal in a query and then graph the
running subtotal for each city group. The data looks like this in the
table (for illustration):
>>>>My City My Date Cumulative Sum Daily Sum
DC 03-Apr-07 6 6
DC 04-Apr-07 20 14
DC 05-Apr-07 0 0
DC 06-Apr-07 24 4
DC 09-Apr-07 26 2
DC 10-Apr-07 0 6
DC 11-Apr-07 32 44
Arlington 12-Apr-07 2 2
Arlington 13-Apr-07 0 0
Arlington 16-Apr-07 3 1
Arlington 17-Apr-07 0 0
>>>>The problem is that the cumulative sum goes to zero when the daily sum
is 0, so the graph is not cumulative. I need the cumulative sum to
never be 0, unless all previous values for the group are zero.
>>>>I was able to use DSum() to calculate a running sum, but it was over
the entire record set, not by city, so that did not work. I know a
report will work for this, too, but I need a query so I can graph the
values.
>>>>Any help is greatly appreciated! I thought this would be trivial, but
I cannot figure out how to do it.
>>>>Best,
Meb
>>>You aren't using Dsum correctly.
Cumulative Sum: Dsum("[Daily Sum]","TableName",
"City = '" & [My City] & "' And "
"My Date <= #" & [My Date])

That shoud be
"My Date <= #" & [My Date] & "#")- Hide quoted text -

- Show quoted text -


Thanks for the direction. Am just learning that it matters for the
syntax whether the field is numeric or character string. I am still
using incorrect criteria. It looks like the critieria are just being
ignored, based on the response I am getting. This is what I have (it
returns just one value which is the total for all rows, rather than a
running subtotal for each [MyCity] group). I am unclear on whether or
not I need the first criteria (on MyPK), which is on a primary key
value that is unique and sequential for each row? I have tried
without this part of the criteria and get the same result.

Also unclear on whether date should be <= or >=? The dates are
arranged in ascending order, by [MyCity].

MySum: DSum("MySum","mytablename","[MyPK] <=" & [MyPK] And "[MyCity] =
'" & [MyCity] & "'" And "[MyDate] <= #" & [MyDate] & "#")

Thanks for the help,
meb
Numbers get surrounded by nothing. Strings by ' or " depending. Dates
by #.

You need to contatenate PK with an &. And change the City. I don't see
a need for [] around some field names either.

DSum("MySum","mytablename","MyPK <=" & [MyPK] &
" And MyCity = '" & [MyCity] &
"' And MyDate <= #" & [MyDate] & "#")

To avoid word wrap I used 3 lines. You really need to look at your &
and how you concatenated the filter string.
Apr 21 '07 #5
Meb,
What version of Access are you using? (please say Access 97)
If so there is a domain function builder wizard available that takes away
about 99% of the PITA of getting the syntax right.
http://support.microsoft.com/kb/172183/en-us

I'm quite sure that it only works as an add-on in Access97.
<me*******@yahoo.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
On Apr 20, 11:28 am, salad <o...@vinegar.comwrote:
>salad wrote:
mebrab...@yahoo.com wrote:
>Hello,
I am trying to create a running subtotal in a query and then graph the
running subtotal for each city group. The data looks like this in the
table (for illustration):
>My City My Date Cumulative Sum Daily Sum
DC 03-Apr-07 6 6
DC 04-Apr-07 20 14
DC 05-Apr-07 0 0
DC 06-Apr-07 24 4
DC 09-Apr-07 26 2
DC 10-Apr-07 0 6
DC 11-Apr-07 32 44
Arlington 12-Apr-07 2 2
Arlington 13-Apr-07 0 0
Arlington 16-Apr-07 3 1
Arlington 17-Apr-07 0 0
>The problem is that the cumulative sum goes to zero when the daily sum
is 0, so the graph is not cumulative. I need the cumulative sum to
never be 0, unless all previous values for the group are zero.
>I was able to use DSum() to calculate a running sum, but it was over
the entire record set, not by city, so that did not work. I know a
report will work for this, too, but I need a query so I can graph the
values.
>Any help is greatly appreciated! I thought this would be trivial, but
I cannot figure out how to do it.
>Best,
Meb
You aren't using Dsum correctly.
Cumulative Sum: Dsum("[Daily Sum]","TableName",
"City = '" & [My City] & "' And "
"My Date <= #" & [My Date])

That shoud be
"My Date <= #" & [My Date] & "#")- Hide quoted text -

- Show quoted text -

Thanks for the direction. Am just learning that it matters for the
syntax whether the field is numeric or character string. I am still
using incorrect criteria. It looks like the critieria are just being
ignored, based on the response I am getting. This is what I have (it
returns just one value which is the total for all rows, rather than a
running subtotal for each [MyCity] group). I am unclear on whether or
not I need the first criteria (on MyPK), which is on a primary key
value that is unique and sequential for each row? I have tried
without this part of the criteria and get the same result.

Also unclear on whether date should be <= or >=? The dates are
arranged in ascending order, by [MyCity].

MySum: DSum("MySum","mytablename","[MyPK] <=" & [MyPK] And "[MyCity] =
'" & [MyCity] & "'" And "[MyDate] <= #" & [MyDate] & "#")

Thanks for the help,
meb

Apr 23 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Wolfgang Kreuzer | last post by:
Hello all, I have two tables - Projects and ProjectStruct Table Projects contains master records of the projects, ProjectStruct allows to define a project herarchie and contains the fields...
1
by: Jeff Blee | last post by:
I hope someone can help me get this graph outputing in proper order. After help from Tom, I got a graph to display output from the previous 12 months and include the average of that output all in...
3
by: Peter Phelps | last post by:
My problem is as follows: I need automatically iterate through a single field in a table and use the values in the field to create an in-statement. Currently, the character limitation in the...
3
by: ChadDiesel | last post by:
I'm new to Access and need some advice. I am trying to setup a database to print labels and reports for our shipments. I have set up a table with fields such as I have taken a snapshot of what...
1
by: ChadDiesel | last post by:
I'm new to access and need some help. I have a form with a shipment destination at the top. I then have a subform that I enter boxes for that shipment. I have several shipments going at a...
10
by: varlagas | last post by:
I execute a query (against DB2 for iSeries), which, in its generic form is as follows. This query runs just fine, executing in a couple of seconds SELECT V.FIELD01, V.FIELD02, V.FIELD03,...
3
by: mochatrpl | last post by:
I am looking for a way to make a query / report display the running average for total dollars. I have already set up a query to provide totals dollars per day from which a report graphly shows...
1
by: eskelies | last post by:
Hello all, Does anyone have any code that will subtotal a query in Access? Thank you. BEFORE: Account Code Principal Income 4 BUY $10.00 $0.00 4 BUY $10.00 $0.00
2
by: murch.alexander | last post by:
Hi all, I have a query that uses a subquery to subtotal one of its fields. This part is working fine. The twist is that when I encounter certain values, I want to reset the subtotal to zero and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.