Queries :: Comparing Data From Current To Previous Years

Oct 9, 2013

I have a table which is used to record electric billing period dates, total kWh and costs for a list of locations each month. I would like to compare the quarter total kWh and costs for this year "2013" against same quarter last year "2012". I have created two queries, the 1st is capturing data from 2013 and the 2nd is capturing data from 2012. I created a 3rd query which joins the 1st and 2nd together by month where fields match. Both tables have the same fields, however there is more records in 2012 than 2013. How can I join the tables together so months that have no data are left blank?

View Replies


ADVERTISEMENT

Problem With Harvesting Records By Date Spaning The Previous And Current Years

Mar 3, 2005

Im working on a make-table query that harvest records for calculation that span a "rolling" 13 week history... my problem is that the query will work if it doesn't have to retrieve work weeks that are prior to the new year. For example, right now is the tenth week of this year so i need to grab the previous 9 weeks of history plus 4 weeks of the prior year. then next week when the query is ran we will be in the 11th work week of the year therefor i will need to harvest the past 10 week plus 3 week of the preivious year. the query works if you don't have to span accross calendar years. here is the SQL of the query below the problem area is in underlined in bold type:
SELECT PORVPHIS.VENDOR_ID, PORVPHIS.VEND_NAME, [Expr2] AS [Fiscal Year], DatePart("yyyy",[DATE_RECV]) AS Expr2, DatePart("ww",[DATE_RECV]) AS Expr1, PORVPHIS.QTY_RECVD, PORVPHIS.PO_UNT_PRC, [PO_UNT_PRC]*[qty_recvd] AS [Total Price], [Expr1] AS [Fiscal Week], IIf([fiscal week]=[LowWeek] And [Expr3]<>0,[total price],0) AS 1, IIf([fiscal Week]=[LowWeek]+1 And [Expr3]<>0,[total price],0) AS 2, IIf([fiscal Week]=[LowWeek]+2 And [Expr3]<>0,[total price],0) AS 3, IIf([fiscal Week]=[LowWeek]+3 And [Expr3]<>0,[total price],0) AS 4, IIf([fiscal Week]=[LowWeek]+4 And [Expr3]<>0,[total price],0) AS 5, IIf([fiscal Week]=[LowWeek]+5 And [Expr3]<>0,[total price],0) AS 6, IIf([fiscal Week]=[LowWeek]+6 And [Expr3]<>0,[total price],0) AS 7, IIf([fiscal Week]=[LowWeek]+7 And [Expr3]<>0,[total price],0) AS 8, IIf([fiscal Week]=[LowWeek]+8 And [Expr3]<>0,[total price],0) AS 9, IIf([fiscal Week]=[LowWeek]+9 And [Expr3]<>0,[total price],0) AS 10, IIf([fiscal Week]=[LowWeek]+10 And [Expr3]<>0,[total price],0) AS 11, IIf([fiscal Week]=[LowWeek]+11 And [Expr3]<>0,[total price],0) AS 12, IIf([fiscal Week]=[LowWeek]+12 And [Expr3]<>0,[total price],0) AS 13, DatePart("ww",Now())-13 AS LowWeek, IIf([fiscal Week]>=[LowWeek] And [fiscal year]<>DatePart("yyyy",Now()),0,[LowWeek]) AS Expr3, [LowWeek] AS week1, [LowWeek]+1 AS week2, [LowWeek]+2 AS week3, [LowWeek]+3 AS week4, [LowWeek]+4 AS week5, [LowWeek]+5 AS week6, [LowWeek]+6 AS week7, [LowWeek]+7 AS week8, [LowWeek]+8 AS week9, [LowWeek]+9 AS week10, [LowWeek]+10 AS week11, [LowWeek]+11 AS week12, [LowWeek]+12 AS week13, PORVPHIS.DATE_RECV, IIf([Expr4]="AS8819" Or [Expr4]="CO1870" Or [Expr4]="GV2510" Or [Expr4]="MC3105",[VEND_NAME],Null) AS ID, PORVPHIS.VENDOR_ID AS Expr4 INTO Tporv

FROM PORVPHIS

WHERE (((PORVPHIS.VENDOR_ID)="AS8819" Or (PORVPHIS.VENDOR_ID)="CO1870" Or (PORVPHIS.VENDOR_ID)="GV2510" Or (PORVPHIS.VENDOR_ID)="MC3105" Or (PORVPHIS.VENDOR_ID)="IM2680") AND ((DatePart("yyyy",[DATE_RECV])) Between DatePart("yyyy",Now())-1 And (DatePart("yyyy",Now()))) AND ((DatePart("ww",[DATE_RECV])) Between DatePart("ww",Now())-1 And (DatePart("ww",Now()))-13));

I hope some one can help me......you can email me by markphillipsii@bellsouth.net or mphillips@dccabinetry.com

thanks Mark

View 1 Replies View Related

Queries :: Datediff From Previous To Current Record

Oct 10, 2013

I want to get the datediff of the last returned date from vacation and the current vacation start date. But how to get difference from the previous record's date to this current record's date. I want to show date difference in an unbound textbox. I have a contiuous form which shows all vacation list of employees. It shows how many times he went vacations and when he went and when he returned.

View 14 Replies View Related

Compare Previous Row's Data To Current Row's Data

Oct 28, 2007

I have a task that will require me to subtract the current time from the previous time as long as the records fall within the same Extract Count. For example:
I have 8 transactions associated with ExtractCount #2 and 8 start/end & processing times. I need to subtract each row's time from the previous row's time. I have a conceptual idea of how to do it but need real help to figure out how to do this using a query.

Thanks,
Phoenix81

View 4 Replies View Related

Queries :: Show Data Older Than Specified Number Of Years From Future Date

Apr 22, 2014

Querying a field for a number of days from today's date but not had a lot of luck finding how to query this from a date in the future.

Currently I have as criteria for the relevant field:

Code:
<[Period Start (dd/mm/yy - less 5 years from financial year end)]

which prompts for a parameter but using this I have to figure out the date 5 years from the future date first and then enter this.

Surely there must be code that allows me to simply enter the date, in the prompt and this then shows me data of 5 years or older equipment!?

View 8 Replies View Related

Reports :: Calculating Current Age In Years And Months

May 7, 2013

I am trying to calculate the age on the day the report is printed in Years and months ( and display it thus) in a report.e.g. 6 years 4 months

View 2 Replies View Related

Queries :: Comparing Data From One Field To Several Others

Aug 27, 2013

I have one table A that has a Name field that I would like to find if it matches any of the cases in table B with 2 other fields: Field 1 or Field 2

There is no way of establishing referential integrity because the Name Field can be found in either Field 1 or Field 2.

How would I go about searching so I can pull in the rest of the data that I need with when the Name is matched either with Field 1 or 2?

View 2 Replies View Related

Queries :: Data Comparing And Updating Incorrectly

Apr 17, 2013

I have 2 tables one Access, one FoxPro both containing similar information. The idea of my query is to compare both tables and update the Access table if the value in the FoxPro table has changed. This works fine for a number of similar queries that I have. However, intermittently, this query will see two values as different when they are exactly the same and replace the value in the Access table with a seemingly random value. I know the "Random" values are from other records within the table but cannot see any link between the values.

View 2 Replies View Related

Queries :: Comparing Data Differences Between Two Identical Access Tables?

Dec 10, 2013

I have two identical Access tables, for example tblDataYesterday and tblDataToday. The data from tblDataToday has updated data changes in it that are different from tblDataYesterday. I have a maximum of 100 fields to review. I want to compare the two tables and display in a query the differences between the data from both tables.

View 1 Replies View Related

Queries :: Evaluating Current Record To Previous Record To Get Counts

Aug 8, 2014

I'm struggling with a query to evaluate current and prior record data. I have a query producing 5000 records. I need to group records by Case ID and compare current date record to previous date record to determine if a team and worker name has changed during the year. I need to count how many times a cases is transferred to and out of a particular team from the beggining of the year. i.e., On 1/1/2014-Team1 has an inventory of 500 cases.

During the month 25 cases are transferred into Team1 and 15 cases are transferred out of Team1. So on 2/1/2014 Team1 begins with an inventory of 510 cases. Throughout the year cases come and go from and to Team1 each month so need to figure out how to create a query to count each change. See attachment displaying how the data is listed and how I invision it to work with the In/out column counts.

Specifically, at the begginig of the year (1/1/14) for case ID 1003 you can see it belongs to Mary in Team1 for January and February. Then in March the case is transferred out and went to Joe in Team 3. So for Mary a "-1" is recorded as a negative count for that Case ID. If later in the year the case is transferred back to Mary a "+1" would be recorded. Respectively evaluated for each of the 5000 records to get a total count for each of the teams by Case ID throughout the year.

I've started with DLookup, tried comparing current month to previous month using DMax. It works as long as I only select one case ID used in a separate query but if I use the whole subset (5000 records) it fails. I can't figure out how to group each set of case IDs and then apply the query.

My attempted query: DLookUp("[Team]","[Team_qry]","[Team_qry]![Date]=#" & CStr(DMax("[Date]","[Team_qry]","[Team_qry]![Date] <#" & CStr([Date]) & "#")) & "#")

View 3 Replies View Related

Comparing Current Time

Apr 13, 2007

I have a table with a list of events and times at which they occur. I would like to compare these times with the current system time, and display perhaps the next 10 events chronologically. Does anyone know how to do this?

Thanks

View 1 Replies View Related

IIF Statement - Calculate Value Based On Comparing Current Date To Dates In Fields

Jun 27, 2013

In my table I have the following 4 fields with the associated date field:

Bronze: 11/1/2013
Silver: 5/1/2014
Gold: 11/1/2014
Platinum: 5/1/2015

I am trying to calculate a value based on comparing the current date to the dates in these fields. I am using the below formula. However, using 6/27/2013 as the current date, my formula keeps resulting in "Bronze" when it should result in "Standard" Am I doing something wrong?

=IIf(Date()<[Bronze],"Standard",IIf((Date()>=[Bronze]) And (Date()<[Silver]),"Bronze",IIf(Date()>=[Silver] And Date()<[Gold],"Silver",IIf(Date()>=[Gold] And Date()<[Platinum],"Gold","Platinum"))))

View 5 Replies View Related

Queries :: How To Create A Query Which Gives Data From Previous Year

Mar 4, 2014

I am trying to create a query which will return records which are from a specific month of the previous year...

To better explain:

If I have sales from 2013 and 2014 in Jan, I want a query which will show me the results from Jan in 2013 only... I'm just unsure on how to make a query do this and it's probably really simple.

But then in 2015 I will want it to show results from 2014 without having to change the expression or criteria.

View 4 Replies View Related

Queries :: Enabling / Disabling Fields According To Previous Data Entry

Aug 6, 2013

I need to create a form to enter data from a survey, and ideally some sections of the form would only be completed when the answer to a first question is "yes". How to do this enabling/disabling of fields for data entry?

View 3 Replies View Related

Values Older Than Current & Previous

Jan 29, 2007

Hi,

I'm new to using access SQL , I'll appreciate if someone can provide the where clause of the statement below:


Provide the count of assets with values older than current and previous versions.

This is needed to determine if we can upload these assets manually.

thanks
b2bmike

View 3 Replies View Related

Modules & VBA :: Getting Age In Years With One Decimal Place (3.5 Years)

Mar 24, 2014

I have a table that lists computers I want to know the age of them for replacement purposes. I am using this function to populate a textbox on a form that updates my table. the results I am getting is a negative whole number I would like to get a positive number with one decimal place. so if computer was shipped September 24, 2010 my textbox would say 3.5 not -3

Here is my function

Code:
Private Sub Form_Load()
Dim theDate As Date
Dim age As Integer
theDate = Nz(Me.compDate.value, 0)
If theDate > 0 Then
age = DateDiff("yyyy", Now(), theDate)
Me.compAge = age
End If
End Sub

View 4 Replies View Related

Compare Current To Previous Record In Query

Aug 14, 2007

I have a table of customers who report trouble on their equipment. I would like to compare the date in the current record to the previous record to see if it occurred within 30 days. Can I do this with an SQL query or expression?

View 2 Replies View Related

Queries :: Average Calculated Field From A Previous Query - Crosstab Data Type Mismatch

Jun 3, 2014

I am trying to construct a crosstab that averages a calculated field from a previous query. It is returning a "Data Type Mismatch" message.

The field I am trying to average is a subtraction of dates to find total days. I assume my field is not a number so I have tried to wrap it in CDbl() to change the type.

The formula is

Code:
CASE_DAYS: CDbl(IIf([Actual Close Date]-[Creation Date]>=0,[Actual Close Date]-[Creation Date],""))

View 5 Replies View Related

Queries :: Exclude Current Month Data

Mar 10, 2014

I have a query that shows data from January to March (which is the current month). is there a possibility to exclude the current month

The query has the following fields

SegmentDate
PCC
AgencyName
SegmentData

View 12 Replies View Related

Conditional Format Based On Previous And Current Record

Feb 4, 2005

I'm having trouble with a tricky conditional format in a continuous subform.

The criteria is based on field [GroupNo] when it changes (increases) which are always listed in numerical order.

Basically all I want to is for the text box colour to alterante (eg blue & yellow)when GroupNo changes value

So it would look something like this....

Group NoID (highlight colour)

1 (yellow)
1 (yellow)
1 (yellow)
2 (blue)
2 (blue)
2 (blue)
3 (yellow)
3 (yellow)
etc etc

btw, although values will always be in order they may not all be output, so it's not just case of odd, even, odd, even (that would be too easy!)

I can retrieve the Previous Record's GroupNo value (via a function) in another text box and compare current GroupNoID with this in the Format Expressions and manage to change the colour, but it won't sustain this new colour for the subsequent same GroupNos, obviously as the values have changed.

So how can I....

Change the colour when the value changes.
Keep this new colour until it the value changes (increases) again.

Many Thanks

View 14 Replies View Related

Forms :: Return To Previous Current Record After Requery

Jul 30, 2013

I have a Main form that has button that loads a new Pop Up form for entering new data that will display in the Main form. When all the data is entered I click on a button that Saves the data and exits the form and then runs Re-query on the main form returning to the record that was current before the requery.

I have the following code:

Private Sub cmdSaveTradeAndExit_Click()
DoCmd.RunCommand acCmdSaveRecord 'Save the current record
DoCmd.Close 'Close the current form
Dim CrId As Integer
CrId = Forms!frmTransactionMainActivePopUp.CurrentRecord
Forms!frmTransactionMainActivePopUp.Requery
DoCmd.GoToRecord , Forms!frmTransactionMainActivePopUp, acGoTo, CrId
End Sub

But I am getting the following error:

Run-time error '2498':

An expression you entered is the wrong data type for one of the arguments

And the following is in yellow in the debug:

Code:
DoCmd.GoToRecord , Forms!frmTransactionMainActivePopUp, acGoTo, CrId

View 4 Replies View Related

Modules & VBA :: Subtracting Value On Current Record From The Value Of Previous Records?

Jun 5, 2013

I want subtrack a value on the current record from the previous record and display the result in text box in subform datasheet. This is done during data entry. The calculation works most of the time and randomly it returns the wrong value. I have the code in an after update event after I enter a number. Here is what my code looks like:

sysHopSpacing = Abs([sysHop1] - DLookup("[sysHop1]", "tblSystemConfiguration", "[sysBaseNumber]=Forms![frmTempestCoordination]![frmSubSystem]![sysBaseNumber] - 1 "))

This is how I generate the sysBaseNumber

sysBaseNumber = Nz(DMax("sysBaseNumber", "tblSystemConfiguration", "sysAccountID=" & Forms!frmTempestCoordination!accAccountID), 0) + 1

I am using DMax so I can keep the subform records with the parent form record.

My results are inconsistant:

This is what I want the subform to do when subtracking from the previous record

syshop1 sysHopSpacing
5
20 15
30 10

Instead I get a result that does not make sense like this:

sysHop1 sysHopSpacing
5
20 15
30 4

I cant trace it down.

View 14 Replies View Related

Same Data Many Years = Confused!

May 10, 2005

I’m after some database advice. It will probably be something simple I can’t see for the wool…

I’m putting together a database that describes specifis small area geographies (Scottish Census output areas). For small area there will be various training category variables with associated counts and a general cost for all training in that geography. On its own this isn’t really a trouble but the database will grow over time with the same data (more or less) appearing each year to add to the database. I have a master geographical index that is used to aggregate small area data to higher areas so I could :-

- have a series of year based tables linked through the small area field and queried on a year look up basis.
- store each years data into the same table as the last and use a year identified to separate the records
- add new fields for all variables for each year across one table although once the number of fields reach 255 or so it would fall to bits.

I think the third is the worst option but I really would be grateful if anyone had any thoughts you could share with me on the best design approach to take.

Any help gratefully received!

Thanks...

View 1 Replies View Related

Multiple Years Data

Aug 22, 2005

Need some help figuring out the best way to handle this.
I have one table - tblEngineVolumes which has columns for each month Jan-Dec for the year 2005 with fields for each printer type.

Type Jan Feb Mar.....
PrinterA 100 50 300
PrinterB 500 25 250

I now have to figure out a way to have both 2005 and 2006 volumes for each printer.

My option so far is are below (there will never be any more than 2 years involved)

Type Jan 05 Jan 06 Feb 05 Feb 06
PrinterA 100 150 50 60
PrinterB 500 400 25 35

OR

Type Year Jan Feb
PrinterA 2005 100 50
PrinterA 2006 150 60
PrinterB 2005 500 25
PrinterB 2006 400 35

Would appreciate any thoughts/suggestions

Thanks,

Toni

View 2 Replies View Related

Auto Fill Field In A Table By Comparing A Given Date Against Current Date?

Aug 18, 2015

I am building a database to track contract of employees so that I can know which contracts are valid and which are expired.

My table has the following fields:

ID (Primary key)
Employee ID (Foreign key to link to the employee table)
Start_Date
End_Date
Status (Either valid or expired)
Challenge

I want when I enter the end date, the system checks the end date against the current date and fills in the status field with either valid or expired as appropriate. For instance if the contract end date is March 10,2016, the status must be filled in the word valid.

View 3 Replies View Related

Tables :: Tracking Several Years Of Data?

Oct 26, 2012

I am looking to track the salary information for my small firm over a number of years. Does it make sense to create a table with multiple fields that would be structured like this (2011401(k), 2011Medical, 2011 LifeInsurance, 2012401(k), 2012Medical, 2012LifeInsurance, etc) or is there a better way to tackle this?

View 14 Replies View Related







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