Rolling Total In A QUERY!!

Mar 7, 2005

is it possible to have a query carry out a running total, so that it counts the record above and the current entry.....

example

Record 1 Total 10 Running total 10
Record 2 Total 10 Running total 20
Record 3 Total 30 Running total 50
Record 4 Total 5 Running total 55

as i said i need this done in a query if Possible...

anyone help?

View Replies


ADVERTISEMENT

Rolling 12-month Total

Feb 25, 2008

Hi all,

I have a problem creating a query calculating a rolling total based on the last 12 months grouped by product.

The table:

Product no. / Period / Gross Rev / Clients
810 / 01-01-2006 / 1.000 / 10
810 / 01-02-2006 / 1.000 / 10
...
810 / 01-01-2007 / 500 / 10
990 / 01-01-2006 / 1.000 / 10
990 / 01-02-2006 / 1.000 / 10

From this table I want to create a rolling total so that the rolling gross rev of product 810 MAR07 is based on APR06-MAR07 data. The same applies to the number of clients. Is this possible?

E.g.
Rolling sum of clients in OCT07 = No. of Clients (NOV06+DEC06+JAN07+ ... +SEP07+OCT07)
Rolling sum of clients in JUN07 = No. of Clients (JUL06+AUG06+ ... +MAY07+JUN07)

The problem is that the output has to be a table/query (a complete list) with following data:
- Product
- Period
- Gross Rev (prenst)
- Clients (present)
- Rolling Gross Rev (last 11 month + the present)
- Rolling Clients (last 11 month + the present)

The table is to be exportet to Excell and used in a pivot.

I have tried using the Dsum function but I have only managed to calculate a running total (not based on the last 12 months). Can somebody help me here?

View 1 Replies View Related

Queries :: Rolling Sum Query?

Apr 17, 2013

I have a table comprised of/grouped by agency, payer source and billing date summing dollars the order/display of the data is the same as the grouping; that is, ordered by agency, payer source, and billing date. The billing date is just every Tuesday of every week. Every once in a while, there is a negative value in terms of dollars for a particular agency/payer source/billing date category. When this happens, a voucher isn't created and in billings that follow that 'rolling negative' amount must be accounted for. Is there a way in which I can produce a value on the line that adds the rolling negatives from prior weeks if they exist? An example is below:

Agency Payer Source Date of Billing Dollars Amt to Release
ABC Patient 1/28/13 $500 $500 *full amt releases because no rolling negatives
ABC Patient 2/04/13 $600 $600 *full amt releases because no rolling negatives
ABC Patient 2/11/13 $-200 *nothing released because negative amt
ABC Patient 2/19/13 $300 $100 *$300 - $200 released because a negative occurred in prior week

View 1 Replies View Related

Rolling 12 Or 6 Month Query

Sep 22, 2011

I have a date field "yyyy/mm/dd"

The data is back up til 2009, but i only want to bring a rolling 12 months of data.

What should my query look like in Access

I did

Month()-12

This gives me an error Message ...

View 2 Replies View Related

Queries :: Calculating Three Different Rolling Averages In One Query?

Jun 26, 2013

Is there a way to calculate three different rolling averages in one query?

I just inherited a database where someone is using three queries to capture the same information only with different time frames. They were calculating a rolling three month average, six month average, and twelve month average. I would like to combine these queries into one to reduce time spent running reports from the database. All three queries are based on one table. One of the columns in that table is called "Month Start Date". That field shows the first day of the month when a call was entered. I can get the query to tell me the first month in the three month period and the first month in the six month period, but I can't get it to calculate the averages of the calls that fall in those time frames. Here is the SQL for the query I have now. When I try to run this, I get the error message that my formula is not part of an aggregate function.

Code:
SELECT DISTINCT DateAdd('m','-2',(Max([Month Start Date]))) AS ThreeMonthStartDate, DateAdd('m','-5',(Max([Month Start Date]))) AS SixMonthStartDate, Max([Month Start Date]) AS MaxStartDate, IIf([Month Start Date] Between [ThreeMonthStartDate] And [MaxStartDate],Avg([All Call Rate]),' ') AS ThreeMonthAverageCallRate, LIST_WITH_TNC.Device, LIST_WITH_TNC.Model, LIST_WITH_TNC.[Item Num]
FROM LIST_WITH_TNC;

Is there a way to make this work?

View 2 Replies View Related

Queries :: Self-Referencing Running Total Used To Calculate Next Total In A Query

Jul 23, 2015

I am trying to create a query that has a self referencing running total based on the values (point totals) of itself (running total of values in the running total column that have already been calculated for all previous records) plus the total of new points being added in the current record, less the total of points being removed in the current record. This running total can never go below 0, if it does, the running total should restart at zero and add in only new points and begin the process again with the next records

I am able to do this in Excel in less than two seconds so I know there has to be a way to port this into a query. I've attached an excel example of what I am exactly trying to do

If it takes multiple queries to complete the required output I am ok with it. In my previous outtakes I have had up to 8 queries but just couldn't seem to do it..

View 9 Replies View Related

Queries :: Rolling 12 Month Query - Keeping Track Of Orders Placed For Given Part Number By Month

May 5, 2014

I am trying to create a database that will keep track of the orders placed for a given part number by month. Currently, my table houses the part number, and the ordered amount for the past three years by month (there are thirty-five columns for every part). My column headings are ORDER_MAY_2013, etc. I would like to set a query up that will look at the column headings and pull the amounts ordered for each part for the past twelve months. In other words, I have three years of data in my table. In my query, I just want one year. However, I don't want to have to rewrite the query every month so that it will pick up the new data. Is there a way to accomplish this?

Is there a better way to build this database? I thought about just have four columns in my table - PART_NUMBER, ORDER_MONTH, ORDER_YEAR, ORDER_AMOUNT. The only problem there, is that every part (there are about 450 parts) would have to be listed 35+ times. That seemed too redundant to me, so I built the table this way. However, now I am having trouble querying against it.

View 2 Replies View Related

Rolling Sum

Aug 3, 2006

Hi,

this is my first question in this site.

I have a database with the following fileds and associated values


areacode dt rainfall
---------------------------
AAA 1/1/2005 10
AAA 2/1/2005 4
AAA 6
. 0
.
.
.
AAA 31/12/2005

SOME BODY HELP ME IN FINDING OUT ROLLING SUM OF RAINFALL
FOR THE WHOLE YEAR ,FOR EVERY FIVE DAYS.

To put it simple ,consider the following data
rainfall rollingsum
1 15
2 20
3 25
4
5
6
7

Also ,i would apprecite on tips how to address the fact that a leap year has 366 days in the above scenario.

View 5 Replies View Related

Rolling Average

Sep 15, 2005

Is there any way i can calculate a rolling average for a field in a record, based on the 10 previous records?

Cheers,
Ben

View 3 Replies View Related

One Query To Return Either Records Within "Date Range" Or "12-Month Rolling"

May 25, 2005

I have a query that selects usage records from a table where a data field falls within a rolling 12-month period that ends on a month and year selected by the user on a form.

PARAMETERS [Forms]![frmReport]![cboMonth] Short, [Forms]![frmReport]![txtYear] Long;
SELECT UsageID, dtUsage, dblUsage
FROM tblUsage
WHERE (((DateDiff("m",[dtUsage],DateSerial([Forms]![frmReport]![txtYear],[Forms]![frmReport]![cboMonth],1))) Between 0 And 11));

I also have a query that pulls data between two dates that the user specifies using two textboxes on a form.

SELECT UsageID, dtUsage, dblUsage
FROM tblUsage
WHERE (((tblUsage.dtUsage) Between [Forms]![frmReport]![txtStartDate] And [Forms]![frmReport]![txtEndDate]));

On the form I have an Option Group control that sets the visible properties of the 4 controls;
12-Month Rolling
cboMonth - Month Combobox
txtYear - User entered year
Date Range
txtStartDate - User entered Start Date
txtEndDate - User entered End Date

What I was planning on doing was adding two new textboxes (txtQryStart & txtQryEnd) and depending on what option is selected, change the dates accordingly

blnDateRange = (Me.optDate = 1)
blnMonth = (Me.optDate = 2)

If blnDateRange Then
Me.txtQryStart = Me.txtStartDate
Me.txtQryEnd = Me.txtEndDate
End If

If blnMonth Then
If Me.cboMonth = 12 Then
EndMonth = 1
EndYear = Me.txtYear + 1
StartMonth = EndMonth
StartYear = Me.txtYear
Else
EndMonth = Me.cboMonth + 1
EndYear = Me.txtYear
StartMonth = EndMonth + 1
StartYear = Me.txtYear - 1
End If
Me.txtQryStart = DateSerial(StartYear, StartMonth, 1) - 1
Me.txtQryEnd = DateSerial(EndYear, EndMonth, 1)
End If

Now I can use one query to accomplish both types of query;
SELECT UsageID, dtUsage, dblUsage
FROM tblUsage
WHERE (((tblUsage.dtUsage) Between [Forms]![frmReport]![txtQryStart] And [Forms]![frmReport]![txtQryEnd]));

This approach works. It saves me from having to duplicate the queries and some future headache if anything needs to be changed in the queries.

What I was wondering is there an better/simpler way to do this?
:confused:

View 2 Replies View Related

Queries :: Rolling Sum In Access

May 8, 2013

Have a table/query result

Sr.NO Name Amt.Tot Amt.Needed
1 Mark 100 24
2 Mark 100 80
3 Tom 150 12
4 Tom 150 45
5 Joe 50 23

Need to add a field which is Amount.LEft so that the table looks like this

Sr.NO Name Amt.Tot Amt.Needed Amt.Left
1 Mark 100 24 76
2 Mark 100 80 -4
3 Tom 150 12 138
4 Tom 150 45 93
5 Joe 50 23 27

The last field is Amt.Tot - Amt.Needed and this should roll over and subtract for all transactions of Mark, then restart again for Tom and then again for Joe. Let me know if there is any confusion on that.

View 5 Replies View Related

General :: Rolling Out A Database Across Several Users

Jun 14, 2013

I have developed a new database using Access 2003, which I need to roll out across various users. Some have XP, some Windows 7, and each of them has different size screens. I guess I will have to adjust the various forms to size to a particular users screen resolutions and sizes.

Is there any way of doing this within the database itself, or do I have have to adjust each form according to the local users PC specification?

View 4 Replies View Related

Rolling 12 Months In A Combo Box In Access

Jul 5, 2015

How to code the rolling 12 months in a combo box?

(1) When I click on the combo box this month, the first value should be 2015-07 (yyyy-mm) and the last one should be 2016-06
(2) When I click on the combo box next month, the first value should be 2015-08 (yyyy-mm) and the last one should be 2016-07.

The combo box will check today's month and will automatically generate the 12 rolling months (include this month).

View 3 Replies View Related

Rolling A Date Back 12 Months Question

Mar 14, 2006

I have a query that takes a date from a selection form. Is there a way to window my data by taking this date and going back 12 months to give me a block of data covering this 12 month window.

Example:
Date entered is 03/dd/06
Date window desired is 04/01/05 thru 03/14/06

View 3 Replies View Related

Modules & VBA :: Loop To Do Rolling 12 Month Average

Aug 13, 2013

May be VBA is a better solution for this:

Say for Material A: I need Access to see that the 1st date is 05/01/2013 and say 365 days out or 12 months (05/01/2013-04/01/2014) the average is 158.6 then 06/2013-05/2014 the average is 146.667 and so on.

Every month is not going to be listed in the results, if there is no month then assume 0.

Sample data attached.

View 7 Replies View Related

General :: Pull All Records In A Rolling 365 Day Period

Apr 4, 2014

What is the best way to pull all records in a rolling 365 day period. Like from 4/3/2013 to 4/4/2014?

View 2 Replies View Related

Queries :: How To Set Rolling Year Based On Individual First Record

Mar 31, 2014

I wanted to know if it is possible to set a rolling year based on the first recorded date for an individual. In other words, my table is updated every time an employee receives a point. The record includes the employee's name (empName), the date (dateOfOccurrence), and the point (occurrencePoint).

I would like to create a query that would be based on a rolling year from the very first record of an employee based on the first dateOfOccurrence. The first date/record of this employee would be the start of the rolling year. I am writing this in SQL in Access 2013.

View 1 Replies View Related

Total Daily Sales Queries By Model/Total

Mar 8, 2008

Hi,

1) I am pretty newbie to this access programming, do forgive me if my questions sounds stupid.

2) Basically I create an application in access capturing or production information for my company. now the top management suddenly wanted whats their main concern:- Total Daily/Monthly, Quarterly, Annual Sales (By Model If possible)

3) I start with daily (Lets don't be too overly ambitious).

4) I try to let user select dates from my calender control and reflect daily sales (in Total & By Model break down) insert into my form.

5) Understand someone told me from my previous post in Calender control I can achieve it either through forms or queries, which is a better way. (in terms of flexibility to change for program maintenance/ scalibility) wise ?

PS: Please forgive my ignorance :o:(

Thanks (In advance) & God Bless.

View 2 Replies View Related

Sub Total Query

Aug 5, 2005

O.K, I am really trying to figure this out from other postings but my limited query experience is limting my understanding of the other posts.

I only know how to use the query wiz and then a bit in design mode.

I have a Query

[ID]pk [Contest Name], [Score]

There will be many records for the same [Contest Name] in the underlying table. Therefore i want to sub total by [Contest Name] so i can then create a report. I have created the report perfectly using the Report support in another posting submitted. But the report does not allow me to order the results as the sum calc is a function on the report. Therefore I am now exploring the Query Sum [Score] order by [Contest Name].

I just need it in a Qery for dummies format.

Go into design mode and put the following in what portion of the query on what line.

I will keep on searching in the mean time

View 1 Replies View Related

Sum Total In A Query

Oct 10, 2005

I have a query which returns charge_cost (based on course cost, whether it went ahead, if hospitals are eligible for charging etc) which is then used in an existing report.

I want to make another report which simply is:

Total training spend for 2004-2005:
£1276.04

And i just want that to be the SUM of charge_cost.

I cant work out how to do this - i did a new query including charge_cost and then created a new field called total_spend: sum([charge_cost]) but i keep getting the message "You tried to execute a query which does not include the specified expression charge_cost as part of an aggregate function"

I have no idea what this means...

View 2 Replies View Related

Total In Query

Aug 29, 2006

hmmm... found another little problem. I've got a list of ingredients with cost and amount from a table, total cost per ingredient is simply amount times cost, how would I go about getting a recipe total by summing the seperate ingredient totals?

View 2 Replies View Related

Total Query

Feb 4, 2007

is there a way to calculate/store total cost value of qty x unitcost in total cost field of same table. if it requires a query, would appreciate guding me how to write it.;) ;)

View 4 Replies View Related

Query For Name Total.

Jul 27, 2007

Hello all,

I again ran into something that I can't figure out.

I have a table:

Date
Time
FirstName
LastName
SSN
InAmount
OutAmount

I need a query to sum up the InAmount and OutAmount into one total based on the SSN. This query is placed into a form that is then placed onto another form. The form is to alert the user if the amount of the Inamount and Outamount of a unique SSN totals above $10,000.01 on the current date.

So for example if on 01/01/07 if SSN=111-11-1111 has an Inamount of $5,000.00 and an OutAmount of $5,000.01 thus totaling $10,000.01, then the person's name will appear on the form list. This will change/clear when the date is 01/02/07.

Any Ideas on how to accomplish this?

View 9 Replies View Related

Query 'Total' Help

Jun 25, 2007

Hi,
I am trying to write a query that will total the number of fields that have matching values. For example i need to have IP addresses added into the table via a form, that bit is done but i need to create a query that will count how many times an individual IP address is added to the list.
So that on the report i can show the list of IP address and instead of showing duplicates it will show how many times it has been added to the table.

Any help on how i could do this would be greatly appreciated.

Cheers
Luke

View 2 Replies View Related

Running Total In Query

Mar 12, 2007

Does anyon ehave any experience of running totals in an access query.
I'm reporting the data through excel not access reports so need a query not a report solution..

I have a table which looks:

RegionCategoryTypeDesc Period_IDPeriod_YTDPeriodTotal
CanadaEventsWSOP Team67Budget15000
CanadaEventsWSOP Team78Budget0
CanadaEventsWSOP Team89Budget0
CanadaEventsWSOP Team910Budget0
CanadaEventsWSOP Team1011Budget0
CanadaEventsWSOP Team1112Budget0
CanadaEventsWSOP Team1213Budget0
CanadaEventsTOTALAll12Budget15000
CanadaEventsTOTALAll23Budget15000
CanadaEventsTOTALAll34Budget15000
CanadaEventsTOTALAll45Budget15000
CanadaEventsTOTALAll56Budget15000

What I would like is to have an additional column which keeps a monthly summary of spend based on running total month 1to 12. All items have months 1 - 12 and are ordered in that fashion.

Any helpo really appreciated.

Simon

View 1 Replies View Related

Total Calculated Query

May 4, 2006

Please look at the attached sample db file and the text file explaining the problem.

Thanks

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved