Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Running Sum Help

Posted on 2016-10-14
31
Medium Priority
?
46 Views
Last Modified: 2016-10-17
Hello Experts,

I used report for running sum. But right now I need running sum by tool number in query to create a graph. I have been trying for days. Tool number is text, shiftend is date, and output is number. Please help I need to have this demo out by next week. Capture.PNG
0
Comment
Question by:Kai Lee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 17
  • 14
31 Comments
 

Author Comment

by:Kai Lee
ID: 41843889
And I keep getting #error with this RunningSum: Val(DSum("Tool Number","Shifts","Tool Number='" & [Tool Number] & "' And ShiftEnd <= #" & [ShiftEnd] & "#"))
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41843896
try using the COUNT and GROUPING functions is sql
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41843898
start with the summing query type (sigma)
0
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 

Author Comment

by:Kai Lee
ID: 41843908
I am sorry I am kind new to Access.
This is my sql looks like right now
SELECT Shifts.ShiftID, Shifts.[Tool Number], Shifts.ShiftEnd, Shifts.[Output_Tools/Shift], Val(DSum("Tool Number","Shifts","Tool Number='" & [Tool Number] & "' And ShiftEnd <= #" & [ShiftEnd] & "#")) AS RunningSum
FROM Shifts
GROUP BY Shifts.ShiftID, Shifts.[Tool Number], Shifts.ShiftEnd, Shifts.[Output_Tools/Shift];
0
 

Author Comment

by:Kai Lee
ID: 41843912
I used Grouping. What is summing query type?
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41843917
once you have the group by (which is different to your image above), you are on the right path.
do you want the count of each tool type? I dont really understand what you want.
also, if you upload the database I can look at the query
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41843921
it sounds like count of tools by day? i.e. grouped by date and tool number?

it also looks as if you are posting multiple threads for the same issue?
0
 

Author Comment

by:Kai Lee
ID: 41843927
Yea I changed few things. I attached images. Sorry I have to cover up some data,Capture1.PNGCapture2.PNG
0
 

Author Comment

by:Kai Lee
ID: 41843932
lol I want to know if there is another way I can create a graph just in case this one doesn't work for me. But I really appreciate your help.
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41843935
do you want the count of tools by day? please explain the requirement
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41843938
once you have the query defined you can use Excel to create the graphs (if Access doesn't cut it)

using VAL( of tool numbers gives a very different result to COUNT
0
 

Author Comment

by:Kai Lee
ID: 41843945
I want running sum of output by tool number and day.
0
 

Author Comment

by:Kai Lee
ID: 41843948
Something like this but by tool number Capture.PNG
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41843949
i.e. SUM output GROUP BY tool number and day

SUM output assumes many output records for each tool?
0
 

Author Comment

by:Kai Lee
ID: 41843965
yes
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41843973
so we are done?
0
 

Author Comment

by:Kai Lee
ID: 41843992
my running sum is still not working Capture.PNG
0
 

Author Comment

by:Kai Lee
ID: 41843993
I want to know what cause the error
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41844000
you didn't display the error.

you would use the SQL SUM function, not your own.
and you don't group by WHERE fields

Please  upload the database.
0
 

Author Comment

by:Kai Lee
ID: 41844025
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41844032
I have a BIG problem: I cannot design databases once I have logged onto https://www.experts-exchange.com because the SSL url clashes with Trusteer rapport and slows Access to a crawl.
So I cannot do both (design your databases and correspond on EE).

If no-one else can solve these issues then I will get a 2nd machine configured and look at the issues later
0
 

Author Comment

by:Kai Lee
ID: 41844036
yea that is fine.
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41844072
In the mean time it would be helpful if you explained exactly what you want in plain text.

e.g.
'I want to see the sum of 'output' for each shift and tool'

1. is the 'running sum' actually a running sum (accumulating as it goes) , or just the total of output grouped by toolnumber and shift ('day')?
2. does the same toolnumber occur many times in a shift?
3. does the exact same shiftend date occur for all tools in a day (is that why you are grouping by shift end?)? if the date/time varies you will get multiple shift- groups in a day

THE DATABASE YOU SENT HAS NO SHIFT TABLE OR RELATED FIELDS. I HAVE TO GO TO MEETINGS NOW, BUT WILL MONITOR EMAILS PERIODICALLY TO SEE IF YOU HAVE SUPPLIED THE CORRECT DATABASE AND ANSWERS TO THE QUESTIONS REGARDING ACTUAL REQUIREMENTS.
0
 

Author Comment

by:Kai Lee
ID: 41844604
Just in case you don't know what a running sum means. A running total is the summation of a sequence of numbers which is updated each time a new number is added to the sequence, by adding the value of the new number to the previous running total.

i want to see the running total of output for each tool. I showed something similar in previous comment.

 Capture1.PNG
0
 

Author Comment

by:Kai Lee
ID: 41844605
This is grouped by PLS and a running sum of percentage.
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41844639
You haven't sent the database yet but the following is some sql for you to start with. You will need to substitute field names where mine are invalid.

SELECT Shift1.[Tool Number], Shift1.[Output], SUM(Shift2.[Output]) AS Running_Total
FROM Shift Shift1, Shift Shift2
WHERE Shift1.[Output] <= Shift2.[Output] or (Shift1.[Output]=Shift2.[Output] and Shift1.[Tool Number] = Shift2.[Tool Number])
GROUP BY Shift1.[Tool Number], Shift1.[Output]
ORDER BY Shift1.[Output] DESC, Shift1.[Tool Number] DESC;
0
 

Author Comment

by:Kai Lee
ID: 41845267
I checked the database i sent. I am sure there is a shifts table and a running sum query. i will try this sql . Thanks.
0
 

Author Comment

by:Kai Lee
ID: 41845275
Why there are shift1 and shift2 two tables in sql? I only have one table. Can you take a look at the attachment that i posted in previous comments? I don't really understand this one.
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41845290
as I have stated 3 times, your attachment contained no 'shift' table - I don't even know if this is the correct database.
see image below.

There are two shift tables needed in the query to generate the running totals. both are aliases of the original shift table. I have not tested the query because I don't have the table and data.
Untitled.bmp
0
 
LVL 7

Accepted Solution

by:
COACHMAN99 earned 2000 total points
ID: 41845307
I have created my own table (image1), and tested the SQL against it (see sql below) and included results (image3)
As you can see, the output is a running sum, grouped by tool. Unfortunately I don't have any more time to spend on this.

 Image1.jpg
SELECT Shift1.ID, Shift1.[Tool Number], Shift1.Output
(
Select Sum (Shift2.Output)
from Shift as Shift2
where Shift2.[Tool Number] = Shift1.[Tool Number]
and Shift2.ID <= Shift1.id
)  AS RunningTotal
FROM Shift AS Shift1;
Image3.jpg
0
 

Author Comment

by:Kai Lee
ID: 41846603
Thank you. I know how you did it. That is pretty clever.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question