Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 52
  • Last Modified:

Running Sum Help

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
Kai Lee
Asked:
Kai Lee
  • 17
  • 14
1 Solution
 
Kai LeeAuthor Commented:
And I keep getting #error with this RunningSum: Val(DSum("Tool Number","Shifts","Tool Number='" & [Tool Number] & "' And ShiftEnd <= #" & [ShiftEnd] & "#"))
0
 
COACHMAN99Commented:
try using the COUNT and GROUPING functions is sql
0
 
COACHMAN99Commented:
start with the summing query type (sigma)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Kai LeeAuthor Commented:
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
 
Kai LeeAuthor Commented:
I used Grouping. What is summing query type?
0
 
COACHMAN99Commented:
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
 
COACHMAN99Commented:
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
 
Kai LeeAuthor Commented:
Yea I changed few things. I attached images. Sorry I have to cover up some data,Capture1.PNGCapture2.PNG
0
 
Kai LeeAuthor Commented:
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
 
COACHMAN99Commented:
do you want the count of tools by day? please explain the requirement
0
 
COACHMAN99Commented:
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
 
Kai LeeAuthor Commented:
I want running sum of output by tool number and day.
0
 
Kai LeeAuthor Commented:
Something like this but by tool number Capture.PNG
0
 
COACHMAN99Commented:
i.e. SUM output GROUP BY tool number and day

SUM output assumes many output records for each tool?
0
 
Kai LeeAuthor Commented:
yes
0
 
COACHMAN99Commented:
so we are done?
0
 
Kai LeeAuthor Commented:
my running sum is still not working Capture.PNG
0
 
Kai LeeAuthor Commented:
I want to know what cause the error
0
 
COACHMAN99Commented:
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
 
Kai LeeAuthor Commented:
0
 
COACHMAN99Commented:
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
 
Kai LeeAuthor Commented:
yea that is fine.
0
 
COACHMAN99Commented:
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
 
Kai LeeAuthor Commented:
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
 
Kai LeeAuthor Commented:
This is grouped by PLS and a running sum of percentage.
0
 
COACHMAN99Commented:
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
 
Kai LeeAuthor Commented:
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
 
Kai LeeAuthor Commented:
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
 
COACHMAN99Commented:
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
 
COACHMAN99Commented:
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
 
Kai LeeAuthor Commented:
Thank you. I know how you did it. That is pretty clever.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 17
  • 14
Tackle projects and never again get stuck behind a technical roadblock.
Join Now