473,503 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Grouping Data based on dates where primary key is overlapping across dates

9 New Member
I have a data set something like this:

Order_Id Shipping_Date Sales
1 6/15/2010 150
2 7/30/2010 100
2 8/1/2010 200
3 7/29/2010 105
3 7/30/2010 78
3 8/2/2010 130
4 7/30/2010 120
4 8/1/2010 210
5 8/4/2010 100
6 7/25/2010 59
7 6/30/2010 214
7 7/1/2010 52
8 7/29/2010 100
8 7/30/2010 59
8 7/31/2010 214
8 8/1/2010 52

Now I not trying to group this data on a monthly sales basis. However since many of the Order_Ids overlap into various months, I am having problems grouping the data on a monthly basis. Ideally I would like to classify the order_id to in middle of shipping dates and have thought of following rules to group the data.

1. Case where single shipping date - Take the date of shipping for grouping - E.g. Order ID 6 should be grouped in 7/25/2010 for total sales of 59 going towards July.
2. Case where there are odd number of dates - take the middle date. E.g. Order ID 3 should be grouped in 7/30/2010 for total sales of 313 going towards July.
3. Case where there are only 2 order IDs - the Order_Id should be grouped in first shipping date. Thus order ID 2 would belong to 7/30/2010 for total sales of 300 going towards July.
4. Cases where there are more than 2 even number of order IDs - take the first date of 2 middle dates. Thus order ID 8 would belong to 7/30/2010 for total sales of 425 going towards July.

Is it possible to somehow set up such kind of rules in Access?

I realize that above rules are quite weird but this is the best I could think of. Any suggestions for changes in above rules are very welcome.

Regards,
Sagar
Aug 5 '10 #1
1 1030
Steven Kogan
107 Recognized Expert New Member
Microsoft has a support article for calculating the median. It seems what you'd like is the median date per order.

Check the support article at http://support.microsoft.com/kb/210581

You would need to modify the code so that the WHERE clause limits the recordset to the orderid for which you want the median date.

You'd also want to modify the vba case where there is an even number of dates so that it selects the first of the two middle dates. For that you could simply modify the line:

Expand|Select|Wrap|Line Numbers
  1. Median = (x + y) /2
to

Expand|Select|Wrap|Line Numbers
  1. Median = y
Aug 5 '10 #2

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

Similar topics

5
5085
by: Mark Broadbent | last post by:
Does anyone know why some genius decided that data based breakpoints are not supported in C#/ vb.net debugging? Is there some technical reason Or has it been done to make breakpointing more...
1
2120
by: Jonathan Woods | last post by:
Hi there, How do i handle grouping same level of data at run time? or any idea? user can view data according to their selection group on the windows form. for example: In customer table,...
2
1084
by: Stephen Witter | last post by:
I am using WriteXml to output data to an xml file, and and XML web control to display it. The code runs fine, however my groups are being ignored. For Instance, the current output is: ...
7
1376
by: E | last post by:
I have encountered a very strange problem that is hard to describe, but hope someone has run across it. I have a form that shows a number of columns from a single table in the upper portion of...
1
1232
by: gozzer101 | last post by:
Hello! I have a small problem with grouping data on reports. The situation is that I have an PersonIDnumber, PersonName, NoPurchases and ProductNumbersAllocated. The person ID is just any number,...
7
9027
by: derekdeben | last post by:
Hi, I have created a report that totals the number of days it took a product to ship by percentage by a date range for a specific location. My data comes from a query with the following headers: ...
1
1665
by: h2lm2t | last post by:
Could anyone please take a look at this? I have a table with 3 columns: ID, ZIP and Count as below: Original Table ID ZIP Count 1 00001 12 2 00002 12 3 00003 ...
2
1757
by: maverick10gk | last post by:
Hello All, This post and my previous post are the last pieces that I need to tie up before my DB tool is complete. What I am trying to do here is to allow a person to select a date range, their...
1
1246
by: Erik Nodland | last post by:
Hi Everyone, Just after some ideas and suggestions on how to do this. I have a large amount of numeric data which I would like to group given a distance as a parameter. IE. If my dataset was...
4
1541
by: singhals | last post by:
I have hundereds of rows of data which goes something like this Date Value 12/31/2009 52 1/1/2009 455 1/1/2005 497 1/1/2009 ...
0
7203
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
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7334
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...
1
6993
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...
0
7462
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...
1
5014
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...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
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...

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.