Cumulative Sum using more than one criteria

M

Mac

Dear All,

I'm trying to create a report that will tell me when a given
department will exceed it's budget, if I can do this with a degree of
accuracy I can try to assign additional funds more appropriately. The
problem is that the only way I can think to do it is to use a
cumulative sum. I have a query at the moment that returns the
department name, it's id number, assigned budget, year and month and
the sum expected to be spent in that month. I can cumulatively sum in
a report (which I have done) and his lists the departments and when
they are expected to go over. The problem is that I now need the same
report only listed by month showing the departments that go in that
month. I've looked at crosstab queries, several posts regarding
running sums but none seem to deal with the problem.
In essence I've got a report that does what example A shows and what I
need is example B:

Example A Example B
Dept. Date Exceeded
Date Dept Exceeding
1 January 2007 January
2007 1
2 March 2007 March
2007 2
3 August 2007 August
2007 3, 4
4 August 2007
N December 2007 December
2007 N

Can anyone help?
TIA

Andy

Current Query Code:
SELECT [Projected Dept Spend- Union II].DeptID, [Projected Dept Spend-
Union II].DeptName, [Projected Dept Spend- Union II].DeptBudget,
[Projected Dept Spend- Union II].Year, [Projected Dept Spend- Union
II].Month, [Year] & Format([month],"00") AS Concatenate, [Projected
Dept Spend- Union II].Expr1005, [Projected Dept Spend- Union
II].Expr1006, Format([SumOfProjNetTrans]/[SumOfPaymentAmount],"Fixed")
AS Percentage, RealTrip.Date AS ActualPassDate, Format([Projected Dept
Spend- Union II].[DeptID]+1,"000") AS MaxLimiter, Format([Projected
Dept Spend- Union II].[DeptID]-1,"000") AS MinLimiter
FROM ([Projected Dept Spend- Union II] LEFT JOIN [Dept Projected &
Current Pyts] ON [Projected Dept Spend- Union II].DeptID = [Dept
Projected & Current Pyts].DeptID) LEFT JOIN [SELECT [PCT
Tracker].DeptID, [PCT Tracker].LetterType, [PCT Tracker].Date
FROM [PCT Tracker]
WHERE ((([PCT Tracker].LetterType)=3))]. AS RealTrip ON [Projected
Dept Spend- Union II].DeptID = RealTrip.DeptID
WHERE ((([Projected Dept Spend- Union II].DeptID) Not In (SELECT
Dept.DeptID
FROM [Director Depts] RIGHT JOIN Dept ON [Director Depts].DeptID =
Dept.DeptID
WHERE ((([Director Depts].DeptClosed)=True)) OR
(((Dept.SupervisorOnly)=True));)));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top