Solved

Running Sum Help

Posted on 2016-10-14
31
29 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
  • 17
  • 14
31 Comments
 

Author Comment

by:Kai Lee
Comment Utility
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
Comment Utility
try using the COUNT and GROUPING functions is sql
0
 
LVL 7

Expert Comment

by:COACHMAN99
Comment Utility
start with the summing query type (sigma)
0
 

Author Comment

by:Kai Lee
Comment Utility
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
Comment Utility
I used Grouping. What is summing query type?
0
 
LVL 7

Expert Comment

by:COACHMAN99
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
do you want the count of tools by day? please explain the requirement
0
 
LVL 7

Expert Comment

by:COACHMAN99
Comment Utility
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
Comment Utility
I want running sum of output by tool number and day.
0
 

Author Comment

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

Expert Comment

by:COACHMAN99
Comment Utility
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
Comment Utility
yes
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 7

Expert Comment

by:COACHMAN99
Comment Utility
so we are done?
0
 

Author Comment

by:Kai Lee
Comment Utility
my running sum is still not working Capture.PNG
0
 

Author Comment

by:Kai Lee
Comment Utility
I want to know what cause the error
0
 
LVL 7

Expert Comment

by:COACHMAN99
Comment Utility
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
Comment Utility
0
 
LVL 7

Expert Comment

by:COACHMAN99
Comment Utility
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
Comment Utility
yea that is fine.
0
 
LVL 7

Expert Comment

by:COACHMAN99
Comment Utility
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
Comment Utility
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
Comment Utility
This is grouped by PLS and a running sum of percentage.
0
 
LVL 7

Expert Comment

by:COACHMAN99
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
Thank you. I know how you did it. That is pretty clever.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now