Queries :: Cross Table By Date

Oct 8, 2014

I have this cross table for a query called OUTPUT. The query has four fields (country, indicator, value and date). I want to cross table by date as follows:

Code:
TRANSFORM Sum(OUTPUT.value)
SELECT OUTPUT.country, OUTPUT.Indicator
FROM OUTPUT
GROUP BY OUTPUT.country, OUTPUT.Indicator
PIVOT OUTPUT.[date];

This works fine but I'd like to visualise the date formatted by quarters instead of dd/mm/yyyy. I have modified my SQL code as follows:

Code:
TRANSFORM Sum(OUTPUT.value)
SELECT OUTPUT.country, OUTPUT.Indicator
FROM OUTPUT
GROUP BY OUTPUT.country, OUTPUT.Indicator
PIVOT "Q" & DatePart("q",OUTPUT.[date]) & " " & Year(OUTPUT.[date]);

My problem is that using the DatePart and Year functions I miss the sorting.

Is there any approach that allows me to keep the date sorted in the cross table?

I have also tried to include the date formatting in the OUTPUT query and to sort the date there. It works fine there but when I create the cross table I again loose the sorting.

View Replies


ADVERTISEMENT

Queries :: MS Access Cross Tab Query - Date Range Filtering

Aug 14, 2013

I just wanted to know how can i set a parameter on the following cross tab query to filter dates. Date field is [pdate By Day].

TRANSFORM Sum([PettyMaster Query2].Amount) AS SumOfAmount
SELECT [PettyMaster Query2].[Petty Cat].Field2, [PettyMaster Query2].[pdate By Day], [PettyMaster Query2].ProjLoc, [PettyMaster Query2].descriptionofpay, [PettyMaster Query2].projno
FROM PettyMaster, [PettyMaster Query2]
GROUP BY [PettyMaster Query2].[Petty Cat].Field2, [PettyMaster Query2].[pdate By Day], [PettyMaster Query2].ProjLoc, [PettyMaster Query2].descriptionofpay, [PettyMaster Query2].projno
PIVOT [PettyMaster Query2].PettyCOA.Field2;

View 11 Replies View Related

Combining Cross Tab Queries

Jan 25, 2006

I have a number of cross tab queries which I run on a weekly basis, each of which is running from a different date field in the database (e.g. one query for orders received based on 'Received Date', another for orders complete based on 'Received Date'. On a weekly basis I have to open each query in design view, edit the start and end date for the week and execute the query. It would save significant time if I could enter a date range once into a form and run the series of queries based on these parameters. Any thoughts?:) :)

View 1 Replies View Related

Queries :: Combine Cross Tab Query

Nov 9, 2013

how to combine 3 cross tab queries values into one daily progress report, transpose format. The values from each crosstab query are

1) Spent hours
2) Qty installed
3) Earned hours.

View 4 Replies View Related

Cross-tab Table

Apr 11, 2006

Dear all,

I have a small problem.....
I hope u 2 help me solving it.....
I cross tab query, with this column:
PIVOT Format([Date],"Short Date")
But as we all know that Format function returns variant(strin), So how can we reorder that column by date...
Sorry for bothering you....

Thanks & Regards

View 6 Replies View Related

Reports :: Combine Two Cross-tab Queries In A Report

Mar 19, 2013

I understand that I can't set multiple "values" in a crosstab query but I need to have both a UPC and a price display in a report(Price List) for Our Exotic Wood selections like so:

Wood Type 4/4 5/4 8/4 12/4 16/4 20/4 24/4

Afr. Mahogany |||| ||| ||| |||| |||| |||| ||||
$15 $20 $30 $40 $50 $60 $70

Rosewood |||| ||| ||| |||| |||| |||| ||||
$15 $20 $30 $40 $50 $60 $70

I have 2 crosstab queries one that gets the price and one that gets the UPC I can join them and get it to print on every other line but there is no way that i can find to print two lines at a time in a report so my question is there a way to achieve the outcome described above with two crosstab queries? do I need more queries or a different kind of query?

View 1 Replies View Related

Queries :: Ordering Columns Cross Tab Query

Nov 26, 2013

I have a cross tab query. Essentially it groups together posted volumes into week numbers for different offices.

However, when I run the query, the order of the columns is not in a logical number order. I get Week 1 then Week 10 then Week 11 and Week 2 is further down the list and then Week 20 comes after that.

I would like if at all possible the Week Numbers to follow after one another i.e. Week 1 first then up to Week 52 in correct number order.

In my Dates Table I do have a SortID column which I hoped would resolve this issue so I could sort on the SortID column however this fails to work.

Attached is the query...

Code:
PARAMETERS [Forms]![frmSumOfVolByCCAndFormat]![cmbOfficeSearch] Text ( 255 ), Forms![frmSumOfVolByCCAndFormat]![txtStartDate] DateTime, Forms![frmSumOfVolByCCAndFormat]![txtEndDate] DateTime;
TRANSFORM Sum(tblTrafficEast.TrafficVolume) AS SumOfTrafficVolume
SELECT tblOffice.CostCentre, tblOffice.OfficeName, tblTrafficFormat.Format, Sum(tblTrafficEast.TrafficVolume) AS [Total Volume]

[Code] ....

View 3 Replies View Related

Queries :: Query To Cross-tabulate Data

Jun 20, 2013

I asked 18 people to each sort 100 statements into piles based on the similarity of the statements. The results are arranged as below.For example:

- Bob sorted statements 1, 3, and 100 into the same pile (Pile ID = 5), and statements 2 and 4 into the same pile (Pile ID = 2).
- Mary sorted statements 1 and 100 into the same pile (Pile ID = 3).

Code:
SubjectID StatementID PileID
------------------------------
Bob 1 5
Bob 2 2
Bob 3 5
Bob 4 2

[code]....

I need to create separate summaries for each Subject. The summary should indicate, for every possible pair of statements (1 & 1, 1 & 2, 1 & 3 ... 100 & 100), a 1 if the person sorted both statements into the same pile and a 0 if they didn't. Identical statement pairs (e.g., 1 & 1) should always get 1.

Code:
StatementIndex1 StatementIndex2 Similarity
1 1 1 (identical statements always get a 1)
1 2 0 (Bob did not sort statements 1 & 2 into the same pile)
1 3 1 (Bob sorted 1 & 3 into the same pile)
1 4 0 (Bob did not sort 1 & 4 into the same pile)

[code]....

I'm assuming a crosstab query is a start, but I couldn't figure out how to set it up.

View 1 Replies View Related

Creating A Table To Cross Index Items In Another Table

Sep 14, 2005

How do I create a table that can cross index items in another table. Maybe I am not using the right terms here so let me show a small example.

Say I have a tables of words.
tblWords
numWordID
txtWord

Then I have some entries, all more or less synonyms of each others
fresh
new
clean

Now I want to create a cross-index table, related to the table "tblWords" where I can select synonyms from words already in the table "tblWords", so if I for the word "fresh" add "new" and "clean" as synonyms or entries, if I then go and look at the word "new" it will already have the synonyms "fresh" and "clean", likewise the entry "clean" will then have the synonyms "fresh" and "new".

Kind of a many to many relationship junction table but only with one table!

I hope my explanation have not been to confusing, but let me know if you need a clarification.

Thanks

View 6 Replies View Related

Queries :: Dynamic Cross Tab Query - Column Sort By Corresponding ID

Apr 23, 2015

I have a dynamic cross tab query - thus the column headings will change each time it is run.

At present the column headings are displayed in alphabetical order - how can I change this so they are based on a different order - eg by the descriptions corresponding ID

View 3 Replies View Related

Queries :: Dlookup Value From 1 Table With Date Ranges From Diff Table With A Single Date?

Mar 12, 2015

i have 2 tables.. 1 with bookings and 1 with a BonusPeriod range.

in the Bookings table there is a field called [ServiceDate]

in the bonus table i have a field called [Period] which is text i also have 2 dates, [StartDate] And [EndDate] i need to Dlookup the Bonus table to return the value of the period table based on where the [ServiceDate] falls.

i dont want to use VBA (i really need it to work within a query that inserts it's data into another table)

i've tried everything but had no joy

Expr1: DLookUp("[Period]","BonusPeriods","[ServiceDate]" Between "#[StartDate]#" And "#[EndDate]#")

Expr1: DLookUp("[Period]","BonusPeriods","[Staff_BookingsAndQuotes_Master].[ServiceDate]" Between "#[StartDate]#" And "#[EndDate]#")

Expr1: DLookUp("[Period]","BonusPeriods","(FormatDateTime([ServiceDate]),"yyyy-mm-dd") Between (FormatDateTime([BonusPeriods]![StartDate]),"yyyy-mm-dd") and (FormatDateTime([BonusPeriods]![EndDate],"yyyy-mm-dd"))))

View 10 Replies View Related

General :: Variation On A Cross Tab Table?

Apr 15, 2013

I have a table similar to the following

TblMinibusTrips

FieldMinibus / FieldDate / FieldCount
A 10/4/2013 1
A 11/4/2013 1
A 12/4/2013 1
B 01/5/2013 1
B 02/5/2013 1
C 01/8/2013 1

I can do a pivot on it no problem to get for instant the first and last dates for each minibus I am however wanting to produce a cross tab from the above that produces a format similar to the following


RowMinibus / Listed Dates
A 10/4/2013 / 11/4/2013 / 12/4/2013
B 01/5/2013 / 02/5/2013
C 01/8/2013

I'm basically only wanting two columns in the related cross tab query result and the "value" within the cross tab needs to be a list of concatenated dates.

I can get all the dates to appear for an individual bus but they are spread across independent columns which results is not concise enough for my objective.

View 1 Replies View Related

Forms :: Cross Ref Form To Table

Jul 16, 2013

I am creating a production type database with different stations (assembly 1, assembly 2, etc) with a master parts list that has every part. I want to cross reference each station input with the master parts list in order to make sure the part is in inventory. Can I create a button or to do this on the form? Or is there a better way? I would cross reference two fields.

View 1 Replies View Related

Cross Referencing Records From A Single Table

Sep 22, 2005

I tried the idea sugested in post (http://www.access-programmers.co.uk/forums/showthread.php?p=423080#post423080) but it didn't seem to give the cross referencing that I had hoped for .... example 1 is related to 4,3, and 5 while 6 is related to 1 thus implying an extended relationship to 4,3, and 5.

In a standard one-to-many I'd look at record 1 and see that it is related to 4,3,5 but if I were to look at record 6 I'd only see that it is related to 1. How would I set up the table relationships to drill further to see that 1 is also related to 4,3,5?

How do you do a many-to-many from one table back to that same table?

tblEvent
EventID(AutoNumber) EventTitle(Memo)
1 memo content
2 data
3 more memo content
4 some info
5 more stuff
6 other text

tblEventRelationships
EventParrent EventChild
1 4
1 3
1 5
6 1
3 2

In addition ... how would one set up the integrity to prevent loops from forming?

View 6 Replies View Related

Tables :: Cross Join TABLE - All Combinations

Sep 5, 2014

I am trying to create a cross join or Cartesian product TABLE, not a query.

I am creating a training database. For each and employee and each training event, I want to know - is this event required, who approved it, and when was it completed. The table I envision looks like this:

Code:
EMPLOYEE_ID EVENT_ID REQUIRED APPROVER EVENT_DATE
1 1 Y WPD 9/5/14
1 2 N

I currently have 39 employees and 473 events - 39*473 = 18447 records

I was able to make a cross join query and use make table, but whenever I add a new employee or event, if I update the make table query I will lose all my existing data.

View 3 Replies View Related

Help Stamp Out Brain-Death: Cross-Tab To Make Table

Aug 28, 2006

Hi -

Desperately need a kick in the butt to restart the cognitive functions.

Am attempting to prepare a FY (1 Jul 05 - 30 Jun 06) rollup of services provided. Have done this for years with very little stress. Lost my notes in a melt-down and now it seems I'm lost.

Situation:

Properly normalized recap of various (about 15) services provided to clients over the one-year period. Created a cross-tab query that sums each of the services and displays columns for each service (represented by ServiceID, e.g. 2019, 2020, etc.)

The cross-tab works perfectly, just now need to turn it into a report. Try to use the Report Wizard, based on the cross-tab. Problem is, it returns no fields to select. Changed strategy and attempted to turn the cross-tab into a make-table query, which, I understand would return a spreadsheet-style table. For these purposes, that's exactly what I need and have examples going back 5 to 6 years how this worked wonderfully.

The cross-tab -> maketable works, but it reverts to the original normalized structure, which is not what is needed.

If someone can help to put me out of my misery, I offer my first-born as a small token.

Thanks,

Bob

View 3 Replies View Related

Queries :: Find Date In Table 1 Closest To Another Date In Table 2?

Mar 17, 2015

I have a table, tblVisits, holding patient's pre and post surgery visits:

Code:

PatientID VisitDate
1 1/5/12
1 3/10/12
1 9/1/13
2 ...

And another table holding patient's surgeries (each patient will have only one surgery)

Code:
PatientID SurgeryDate
1 4/1/12
2 ...

I need to compare these two tables and create a variable that indicates which pre-surgery visit date (i.e., VisitDate < SurgeryDate) is closest to the surgery date. In the above example, it would return:

Code:
PatientID VisitDate ClosestToSurgery
1 1/5/12
1 3/10/12 Yes
1 9/1/13
2 ...

I've tried various MIN and MAX approaches and can't seem to get it right.

View 2 Replies View Related

Queries :: How To Keep Only The Most Current Date Record In Table

Mar 8, 2014

I have this table that records sales events for properties, with multiple sales records for some parcels. Each parcel has unique field: MapTaxlot. I want to create a select query or make table query that shows only the most recent sale event for each parcel. Instrument_Date is the date field for the sales records.

See attached example of the data table below.

What is the simplest method to accomplish this?

TableSnip.JPG

View 5 Replies View Related

Queries :: How To Lookup Date And Return Value From Another Table

Jul 30, 2015

Basically, i have a table ("Transaction") with payment date and another table ("Control") with accounting dates and corresponding year/month.

Objective: I need to know which accounting year or month these payment date fall under.

Example: If the payment date is 18 Dec 2013, the accounting year should read as 2013 and the accounting month should read as 12.

In excel, this is very simple using vlookup.

I tried for hours using access dlookup query and i'm still stucked ..

View 4 Replies View Related

Queries :: Linked Table Date Is Text

Jul 22, 2013

I'm trying to create a query that will convert the text fields that have dates in them to dates. I cannot change the table this is linked to, our group does not own it. I tried doing a cdate() on it, and it displays the test as a date. But then when I try to run a query based off of this one, to give me inbetween dates it returns all dates as if it is a text. I know my second query works, because I copy the table and changed the text to date fields and it works then.

View 10 Replies View Related

Queries :: Calls Table - Finding Last Contact Date

Aug 7, 2014

There are three tables. An [Action Register] table, a [Calls] table and a [tblContacts] table. The Contacts are common to both.

The Calls table records calls to customer by date

The Action Register table records issues that Customers send in by Open date.

I am trying to make a query where we see the latest date the customer was contacted regardless of which table.

I created two queries.

qryLastCallDate finds the max date from the Call table:

SELECT Max(Calls.CallDate) AS MaxOfCallDate, tblContacts.ContactName
FROM Calls LEFT JOIN tblContacts ON Calls.ContactID = tblContacts.ContactID
GROUP BY tblContacts.ContactName
ORDER BY Max(Calls.CallDate);

qryLastIssueDate finds the max date from the Action Register table:

SELECT Max([Action Register].Open) AS MaxOfOpen, tblContacts.ContactName
FROM tblContacts RIGHT JOIN [Action Register] ON tblContacts.ContactID = [Action Register].Contact
GROUP BY tblContacts.ContactName
ORDER BY Max([Action Register].Open);

The problem I am having is that if I use Left Join I can see all the records from the Calls table but not all from the Action Register table. And vis versa if I use Right Join. This is because sometimes we have calls but no issues in the Action Register table and sometimes issues with no calls.

This is my Left Join query using a Min Max Module I found here: [URL] ....

SELECT qryLastCallDate.ContactName, qryLastCallDate.MaxOfCallDate, qryLastIssueDate.MaxOfOpen, qryLastIssueDate.ContactName, DateValue(MaxOfList([MaxOfCallDate],[MaxOfOpen])) AS [Last Contact], ([Last Contact]+21) AS NextCall
FROM qryLastCallDate LEFT JOIN qryLastIssueDate ON qryLastCallDate.ContactName = qryLastIssueDate.ContactName;

How do I get to see ALL the records from both queries.

View 3 Replies View Related

Queries :: Formatting Date On Transfer To Temp Table

May 11, 2015

I am trying to export into a temp table (all text fields because it will be going into a text export later) and I'm having difficulty adding 0:00:00 onto the value of "ApptdateLast" for the update...

INSERT INTO cbt_Export_Temp ( TransactionType, ID, ApptdateLast )
SELECT "Add" AS TransactionType, "BC" & [TransId] AS ID, dbo_Info.ApptdateLast & " 0:00:00" AS ApptdateLast
FROM dbo_examInfo

View 2 Replies View Related

Queries :: Possible To Sort A Table Drop Down Box By Date Within A Query?

Oct 3, 2013

Is it possible to sort a natural table drop down by date from within a query? What im doing:

1. making a query that has certain results displayed
2. within the query you can select one of the field boxes and it has a list of all the items in that table.
3. is it possible to sort this natural table listing from within the query. I have attached a screenshot. Same thing happens with the client ID listing from within the query. Want to know if it is possible or not to sort those. I cant see how.

View 1 Replies View Related

Queries :: Latest Date Per FName - Query From Table

Nov 23, 2014

How do I query from this table:

ORIGINAL_table

FName | END_Date|
--------|---------------|
John| Oct 09, 2014|
John| Oct 15, 2014|
John| Oct 25, 2014|
Mike| Dec 10, 2014|
Mike| Dec 15, 2014|
Mike| Dec 20, 2014|
Mike| Dec 25, 2014|
Jimm| Dec 10, 2014|
Jimm| Dec 15, 2014|
Jimm| Dec 20, 2014|
Alex| Dec 01, 2014|
Alex| Dec 05, 2014|
Alex| Dec 10, 2014|
Thom| Nov 10, 2014|
Thom| Oct 10, 2014|
Thom| Aug 10, 2014|

The output will be:

FName | END_Date|
----------|---------------|

John| Oct 25, 2014|
Mike| Dec 25, 2014|
Jimm| Dec 20, 2014|
Alex| Dec 10, 2014|
Thom| Nov 10, 2014|

The query table(output) will just have to be latest date("END_Date") per "FName"

View 1 Replies View Related

Queries :: Query Result For Latest And Max Date From Table

Apr 26, 2013

I try to make a query that can show me data from the lastest and max date from the table i have ( see attchment file )

I try using max but still the result is not what i am looking for...

View 6 Replies View Related

Queries :: Find Result In A Table Containing Highest Date Value - Too Many Results

Jul 6, 2013

Setup a query to find the result in a table containing the highest date value.

The query is linked to two tables : Payment information containing the date, and tenant information containing the tenant.

In the query i have selected the tenant name from the payment table (which is linked to the tenant name in the payment table) and the payment terms - ie weekly / monthly etc. I've then selected the payment date from the payments table.

The query should return for each tenant the latest date they paid.

On the pay date i selected the Max option.

But it shows me more than one record.

SQL query is shown here

SELECT Max(tblPayments.DateDue) AS MaxOfDateDue, tblLease.cboPaymentTerms, IIf([cboPaymentTerms]=2,DateAdd("ww",1,[DateDue]),IIf([cboPaymentTerms]=3,DateAdd("ww",2,[DateDue]),IIf([cboPaymentTerms]=4,DateAdd("ww",4,[DateDue]),IIf([cboPaymentTerms]=1,DateAdd("m",1,[DateDue]),"n/a")))) AS calcNextPayDueDate, tblPayments.cboTenant
FROM tblPayments INNER JOIN tblLease ON tblPayments.cboTenant = tblLease.cboTenant
GROUP BY tblLease.cboPaymentTerms, IIf([cboPaymentTerms]=2,DateAdd("ww",1,[DateDue]),IIf([cboPaymentTerms]=3,DateAdd("ww",2,[DateDue]),IIf([cboPaymentTerms]=4,DateAdd("ww",4,[DateDue]),IIf([cboPaymentTerms]=1,DateAdd("m",1,[DateDue]),"n/a")))), tblPayments.cboTenant;

View 2 Replies View Related







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