473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Report Howto Needed

I'm desiging a report to show the age of orders. Part of the report is shown below:

Age of Order

<30 | 31-59 | 60-89|

Unit 3
------------------------------------------------------------------------------------
Unit 4



I need a hand in devising a method to "roll Up" by age bracket (i.e. <30, 31-59). In other words, I know I can calculate the age of each order using a date function. The question I have is how do I then count the orders that are <30 days old, the ones that are 31-59 days old, etc, and then put the count in the correct "bucket" of the report??????
Mar 24 '08 #1
7 1689
Stewart Ross
2,545 Expert Mod 2GB
Hi. In summary, to show data in banded groupings you create a separate table to hold the band limits, create a new query which has the relevant order data (with the order days old value), add the band table WITHOUT joining it on any field, then include a criterion in the query to select the age band where the order days old is between the minimum and maximum for that band.

The attached Access 2003 sample DB has two tables: Order Days Banded, which stores the day bandings, and a 'dummy' order details table which is standing in for what would normally be a multiple-join Order Details query that has your calculated Order Days field.

The two queries show how the banding is done (qryOrderBanded), and an example of other uses for the banded data (counting the number of orders falling within each band in this case).

Sample SQL for the qryOrderBanded table is:
Expand|Select|Wrap|Line Numbers
  1. SELECT [Order Details].[Order ID], ..., [Order Details].[Days Old], [Order Days Banded].[Band], [Order Days Banded].[Band Name]
  2. FROM [Order Days Banded], [Order Details]
  3. WHERE ((([Order Details].[Days Old]) Between [Band Min] And [Band Max]))
  4. ORDER BY [Order Days Banded].[Band] DESC;
and for the count query is
Expand|Select|Wrap|Line Numbers
  1. SELECT qryOrderBanded.[Band], qryOrderBanded.[Band Name], Count(qryOrderBanded.[Band]) AS [No of Orders]
  2. FROM qryOrderBanded
  3. GROUP BY qryOrderBanded.[Band], qryOrderBanded.[Band Name]
  4. ORDER BY qryOrderBanded.[Band] DESC;
  5.  
-Stewart
Attached Files
File Type: zip Order Days.zip (12.0 KB, 84 views)
Mar 24 '08 #2
Hi. In summary, to show data in banded groupings you create a separate table to hold the band limits, create a new query which has the relevant order data (with the order days old value), add the band table WITHOUT joining it on any field, then include a criterion in the query to select the age band where the order days old is between the minimum and maximum for that band.

The attached Access 2003 sample DB has two tables: Order Days Banded, which stores the day bandings, and a 'dummy' order details table which is standing in for what would normally be a multiple-join Order Details query that has your calculated Order Days field.

The two queries show how the banding is done (qryOrderBanded), and an example of other uses for the banded data (counting the number of orders falling within each band in this case).

Sample SQL for the qryOrderBanded table is:
Expand|Select|Wrap|Line Numbers
  1. SELECT [Order Details].[Order ID], ..., [Order Details].[Days Old], [Order Days Banded].[Band], [Order Days Banded].[Band Name]
  2. FROM [Order Days Banded], [Order Details]
  3. WHERE ((([Order Details].[Days Old]) Between [Band Min] And [Band Max]))
  4. ORDER BY [Order Days Banded].[Band] DESC;
and for the count query is
Expand|Select|Wrap|Line Numbers
  1. SELECT qryOrderBanded.[Band], qryOrderBanded.[Band Name], Count(qryOrderBanded.[Band]) AS [No of Orders]
  2. FROM qryOrderBanded
  3. GROUP BY qryOrderBanded.[Band], qryOrderBanded.[Band Name]
  4. ORDER BY qryOrderBanded.[Band] DESC;
  5.  
-Stewart
Stewart,

Thanks for helping me to get the ball rolling...I'll study this example and try to encorporate your suggestion.
Mar 24 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi. Sorry to hear that you found problems with the Zip file - I checked by downloading it again myself (to another drive - it has two tables, two queries and no forms at all, just as it was sent. Is it A2003 you have? I will attach another Zip in Access 97-converted format as another try...

-Stewart
Attached Files
File Type: zip Order Days 97.zip (13.7 KB, 88 views)
Mar 24 '08 #4
Hi. Sorry to hear that you found problems with the Zip file - I checked by downloading it again myself (to another drive - it has two tables, two queries and no forms at all, just as it was sent. Is it A2003 you have? I will attach another Zip in Access 97-converted format as another try...

-Stewart
Stewart,

I think I got it....One last question...On the report, how would I reference the count of the number of orders in the <=30 bucket??
Mar 24 '08 #5
Stewart,

I think I got it....One last question...On the report, how would I reference the count of the number of orders in the <=30 bucket??
Stewart,

I added one additional criteria...a UNIT ......So in my final table I have band, band name, number of orders, and unit...obviously, unit name (i.e. Unit 3) will appear multiple times in the table. In the report, how would I reference Unit 3's number of orders that are <=30, the number that are 31-59, etc, etc???
Mar 24 '08 #6
Stewart Ross
2,545 Expert Mod 2GB
Stewart,

I added one additional criteria...a UNIT ......So in my final table I have band, band name, number of orders, and unit...obviously, unit name (i.e. Unit 3) will appear multiple times in the table. In the report, how would I reference Unit 3's number of orders that are <=30, the number that are 31-59, etc, etc???
Hi. To include the Units in the count query grouping, just add the Unit to the count query as a group-by field (the default). In your report, if you want to refer to the count of any one unit you join the count query back to the report's recordsource query. To do this without affecting the queries you already have create a new query and base it on your existing report recordsource. Add to that the order count query and join it to the report query on the unique field or fields - the unit number or unit number and order ID I guess in your case. Change your report to refer to the new query instead of its original recordsource and you can then include the count for each unit as a repeated value on each row referring to that unit in your report.

Alternatively you can use an unbound field in your report and do a DLookup to find the value from the count query, but joining the count query back for report purposes is what I would do (and is the approach I use when doing similar work, in my case for age banding of student groups rather than day banding of orders).

An advantage of using the separate day band table is that you can always add new bandings or change the min/max thresholds and names of the existing bands without altering your count query and report in any way.

-Stewart
Mar 25 '08 #7
Hi. To include the Units in the count query grouping, just add the Unit to the count query as a group-by field (the default). In your report, if you want to refer to the count of any one unit you join the count query back to the report's recordsource query. To do this without affecting the queries you already have create a new query and base it on your existing report recordsource. Add to that the order count query and join it to the report query on the unique field or fields - the unit number or unit number and order ID I guess in your case. Change your report to refer to the new query instead of its original recordsource and you can then include the count for each unit as a repeated value on each row referring to that unit in your report.

Alternatively you can use an unbound field in your report and do a DLookup to find the value from the count query, but joining the count query back for report purposes is what I would do (and is the approach I use when doing similar work, in my case for age banding of student groups rather than day banding of orders).

An advantage of using the separate day band table is that you can always add new bandings or change the min/max thresholds and names of the existing bands without altering your count query and report in any way.

-Stewart
Thanks, Stewart. I think this is EXACTLY what I needed!!
Apr 1 '08 #8

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

Similar topics

4
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
1
by: sean | last post by:
Hi all, Is it possible to create as follow: page1 --------------------------------------- < Report Title > Line1 item1 desc1 etc.... Line2 item2 desc2 etc.... Line3 item3 desc3 etc.... Line4...
2
by: Tom | last post by:
I have a report where one field tends to be rather lengthly and ends up being several lines long while another field has several short entries. The problem I have is that the first of the short...
1
by: shaqattack1992-newsgroups | last post by:
I know this is kind of a weird question, but is there anyway to give a subreport control of a main report? I posted my situation earlier about having drawings print out after a group. I have a...
1
by: khalsaiskingraajkaregakhalsa | last post by:
hello all, i m using vb.net.i want to make a crytal report which contains a subreport in the header .the subreport in the header will display class info like class ,class teacher,class monitor...
1
by: Brad | last post by:
Thanks for taking the time to read my question. I have a table of data that has Date, Data and Category. I need to show, in a report, each Categories Data by Date. The Date has to be it's own...
1
by: lorirobn | last post by:
Hi, I have a report that works just fine. Now I would like to add the capability to choose selection criteria to limit what is displayed. I created several reports that do this, but they used...
5
by: ladybug via AccessMonster.com | last post by:
I am trying to create a report using multiple tables. The first table has Employee info in it (name and id's). the next three tables have employee info for training, test, scores, etc. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.