473,513 Members | 2,545 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weekly Parameters in a Crosstab Query

Boxcar74
42 New Member
Hi,

This is probably easy but I’m can’t find the answer. I’m using Access 2003 (mdb).

Ok Here is my Issue I’m running a crosstab query to retrieve data for the Last 13 weeks from a single date field.

I can get the data using the Parameters:

WHERE ((([DATE]-Weekday([DATE])+1) Between Date()-96 And Date()-7))

This will work but on some days I get the current week.

I tried Between Week()-14 And Week()-1)) and I tried Between Weekly()-14 And Weekly()-1)).

With Both I get a “Undefined Function ‘Week’ in Expression” Error.

So my Question is there a Week function for parameters?

If not any recommendations for the parameter?

Not a big deal for me now but I’m running this expression in 30 or 40 queries and I want it to be efficient and get it right the first time.

Thanks,
Boxcar
May 23 '07 #1
7 3669
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi Boxcar

I'm not sure exactly what you are looking for but try something like this ...

Expand|Select|Wrap|Line Numbers
  1. WHERE DateDiff("w", [Date], Date()-(Weekday(Date())+1)) <= 13
  2.  
May 25 '07 #2
Boxcar74
42 New Member
That is what I was looking for!!!!!! (well kind of)

But it is pulling this weeks (the current week) data as well.

So today is 5/29 now I get 5/27 and twelve other weeks.

But I need 5/20 and twelve weeks back.

I keep trying different expression, but none work. I’ll probably get it.

But if anyone know an easy way please post it.

Thanks!
May 29 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1. WHERE DateDiff("w", [Date], Date()-(Weekday(Date())+8)) <= 13
  2.  
May 29 '07 #4
Boxcar74
42 New Member
Sorry to bother you.

I feel like an Idiot +8 made sense. But now I get days going back 13 weeks.

Here is the code
TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
FROM DailyCSTMs
WHERE (((DateDiff("ww",[Date],Date()-(Weekday(Date())+8)))<=13))
GROUP BY DailyCSTMs.CATEGORY
PIVOT DailyCSTMs.DATE;


Not sure if I mentioned this but as you can see it is a Crosstab Query.

And each record in the DB is by individual date.

It works this way I was just trying to find a better way:
TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
FROM DailyCSTMs
WHERE ((([DATE]-Weekday([DATE])+1) Between Date()-96 And Date()-7))
GROUP BY DailyCSTMs.CATEGORY
PIVOT [DATE]-Weekday([DATE])+1;


I'm Trying to make it Idiot Proof. Because I have Many reports running this query (and similar ones) at different time of the week.

I think one i got works fine.

mmccarthy If you have any Ideas or a better soulution it is appreicated.

Thansk you this site is great !!!
May 30 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try keeping the same pivot at the old query.
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
  2. SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
  3. FROM DailyCSTMs
  4. WHERE (((DateDiff("ww",[Date],Date()-(Weekday(Date())+8)))<=13))
  5. GROUP BY DailyCSTMs.CATEGORY
  6. PIVOT [DATE]-Weekday([DATE])+1;
  7.  
May 30 '07 #6
Boxcar74
42 New Member
For some Reason that query had 16 weeks including this week.

With some trial and error. I don't know why or how.

I got this to work:
TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
FROM DailyCSTMs
WHERE (((DateDiff("ww",[Date],Date()-(Weekday(Date())+1)))>-1 And (DateDiff("ww",[Date],Date()-(Weekday(Date())+1)))<=12))
GROUP BY DailyCSTMs.CATEGORY
PIVOT [DATE]-Weekday([DATE])+1;


It may not be the best but is works.

Thank You Very Much !!!!!!
May 30 '07 #7
MMcCarthy
14,534 Recognized Expert Moderator MVP
For some Reason that query had 16 weeks including this week.

With some trial and error. I don't know why or how.

I got this to work:
TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
FROM DailyCSTMs
WHERE (((DateDiff("ww",[Date],Date()-(Weekday(Date())+1)))>-1 And (DateDiff("ww",[Date],Date()-(Weekday(Date())+1)))<=12))
GROUP BY DailyCSTMs.CATEGORY
PIVOT [DATE]-Weekday([DATE])+1;


It may not be the best but is works.

Thank You Very Much !!!!!!
You're welcome. If it works don't mess with it :)
May 31 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3403
by: Bryan | last post by:
I've been looking over this newsgroup, but I can't find an answer to my problem. I see that a few others have posted this issue over the years, but none of them got a response. I'll give it another shot. I have a report that is based on a crosstab query. The crosstab query is based off of another query, and that has a parameter in the...
7
1900
by: newguy | last post by:
I am trying to get the totals of a table by client by type of income. This query will get what I am looking for with each unique combination as a row: SELECT Sales.Client, BillCode.Type, Sum(Sales.Amount) FROM Invoice_Details INNER JOIN BillCode ON Sales.BillCode = BillCode.id GROUP BY Client, Type;
8
6059
by: Penny | last post by:
(Access 2003 Multiuser Split DB, Windows XP Pro) Hi All, I would really appreciate just some basic tips on how to make a Crosstab Form based on a Crosstab Query. The query always has the same number of records(generated from a table of predefined 'timeslots'). The number of columns(one for each Consultant) varies depending on how many of...
14
3472
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity. However, the expectation changes - it may be 60% for a while, then change to 50%. Initially, I was averaging the expectation, along with the...
6
2823
by: Michael R | last post by:
Please help me with this. I have a form in which I would like to present results from a CrossTab query in a subform. I don't need the query to be bounded to a master field. Also, I have a parameter in the query as one of the main form controls. Please look at the query: PARAMETERS !! Long; TRANSFORM Sum(LoansSumAmountAndYearAndCity.Amount)...
4
6460
by: m.wanstall | last post by:
I have a crosstab query that compiles data for Months of the year. I have a stacked select query on top of that crosstab query that uses the latest 2 months data and exports it to a fixed length flat file. Ideally I would like to be able to just select the Last 2 Columns of the Crosstab query as inputs to the Select query WITHOUT having to go...
5
3157
by: odavison | last post by:
I've created a Crosstab Query displaying the Consultant ID and the corresponding amount of Appointments they have on a specific date, as well as a count of the number of appointments. I am trying to get it to display as a subform in the Consultant Form, and I have read around stating that you need to declare your parameters in order for it to...
6
13222
by: lisacrowe | last post by:
I have a simple database recording complaints. A crosstab query is based on a query which returns resolved complaints only. The crosstab has the field Complaint Type as a row heading and Outcome as a column heading. I want to be able to select complaints which were resolved in a particular date range (field is Date resolved). This field is in...
11
6159
ollyb303
by: ollyb303 | last post by:
Hello, I am using a dynamic crosstab report to track performance statistics for my company and I have hit a problem. I would like the option to track stats daily (for the last 7 complete days), weekly (for the last 6 weeks) and monthly (for the last 6 complete months). Daily and monthly are not causing me a problem - I have used the...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5704
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4759
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.