473,395 Members | 1,530 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,395 software developers and data experts.

Calculating sales based on date range

FOE2272
20
I am working on a report that will Sum the Sales (Bid Price Field) that are still Active (Bid Status Field) for the past
1 Week,
2 Weeks,
3 Weeks,
4 Weeks,
30 Days,
60 Days,
90 Days,
120 Days,
150 Days,
180 Days &
over 180 Days
using the (Bid Date Field) from the current date back.

I have a query set up to only show Active bids, figured that was a good place to start, but how to I get it to return the Sum of the Sales for each of the date ranges?
May 31 '07 #1
5 2713
MMcCarthy
14,534 Expert Mod 8TB
OK this is not straightforward but lets try some stuff out to see if we can get it to work. You don't give the date field you reference so I just refer to it as [DateField].

Expand|Select|Wrap|Line Numbers
  1.  SELECT Sum([Bid Price Field]) A SumBidPrice, 
  2. IIf(DateDiff("d",[DateField],Date())<=7,"1 Week",
  3. IIf(DateDiff("d",[DateField],Date())>7 And DateDiff("d",[DateField],Date())<=14,"2 Weeks",
  4. IIf(DateDiff("d",[DateField],Date())>14 And DateDiff("d",[DateField],Date())<=21,"3 Weeks",
  5. IIf(DateDiff("d",[DateField],Date())>21 And DateDiff("d",[DateField],Date())<=28,"4 Weeks",
  6. IIf(DateDiff("d",[DateField],Date())>28 And DateDiff("d",[DateField],Date())<=30,"30 days",
  7. IIf(DateDiff("d",[DateField],Date())>30 And DateDiff("d",[DateField],Date())<=60,"60 days",
  8. IIf(DateDiff("d",[DateField],Date())>60 And DateDiff("d",[DateField],Date())<=90,"90 days",
  9. IIf(DateDiff("d",[DateField],Date())>90 And DateDiff("d",[DateField],Date())<=120,"120 days",
  10. IIf(DateDiff("d",[DateField],Date())>120 And DateDiff("d",[DateField],Date())<=150,"150 days",
  11. IIf(DateDiff("d",[DateField],Date())>150 And DateDiff("d",[DateField],Date())<=180,"180 days",
  12. "> 180 Days")))))))))) AS NumDays
  13. FROM Table3
  14. GROUP BY IIf(DateDiff("d",[DateField],Date())<=7,"1 Week",
  15. IIf(DateDiff("d",[DateField],Date())>7 And DateDiff("d",[DateField],Date())<=14,"2 Weeks",
  16. IIf(DateDiff("d",[DateField],Date())>14 And DateDiff("d",[DateField],Date())<=21,"3 Weeks",
  17. IIf(DateDiff("d",[DateField],Date())>21 And DateDiff("d",[DateField],Date())<=28,"4 Weeks",
  18. IIf(DateDiff("d",[DateField],Date())>28 And DateDiff("d",[DateField],Date())<=30,"30 days",
  19. IIf(DateDiff("d",[DateField],Date())>30 And DateDiff("d",[DateField],Date())<=60,"60 days",
  20. IIf(DateDiff("d",[DateField],Date())>60 And DateDiff("d",[DateField],Date())<=90,"90 days",
  21. IIf(DateDiff("d",[DateField],Date())>90 And DateDiff("d",[DateField],Date())<=120,"120 days",
  22. IIf(DateDiff("d",[DateField],Date())>120 And DateDiff("d",[DateField],Date())<=150,"150 days",
  23. IIf(DateDiff("d",[DateField],Date())>150 And DateDiff("d",[DateField],Date())<=180,"180 days","> 180 Days"))))))))));
  24.  
Jun 1 '07 #2
FOE2272
20
Thank you, That worked great. One more question.

I am also counting the # of bids in the query

How do I get the sums of each Bid Price (from the previous question) and the Count of Bids (I have it in the query by each of the "NumDays" values) into a report so that I can have each result in a different textbox. (for running calculations)

Example:
the "SumBidPrice" for "1 Week" in a textbox,
the "SumBidPrice" for "2 Weeks" in a different textbox,
ETC...

Becuase I will need the "summed" and "separate" on the report.
Jun 1 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Thank you, That worked great. One more question.

I am also counting the # of bids in the query

How do I get the sums of each Bid Price (from the previous question) and the Count of Bids (I have it in the query by each of the "NumDays" values) into a report so that I can have each result in a different textbox. (for running calculations)

Example:
the "SumBidPrice" for "1 Week" in a textbox,
the "SumBidPrice" for "2 Weeks" in a different textbox,
ETC...

Becuase I will need the "summed" and "separate" on the report.
OK change the query to show count of bids as follows

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT Sum([Bid Price]) As SumBidPrice, Count([Bid Price] As CountBids
  3. IIf(DateDiff( ......
  4.  
I'm afraid this is the best I can do with a crosstab query.

Expand|Select|Wrap|Line Numbers
  1.  
  2. TRANSFORM Sum([SumBidPrice]) AS SumOfSumBidPrice
  3. SELECT Sum([SumBidPrice]) AS [Total Of SumBidPrice], CountBids
  4. FROM QueryName
  5. GROUP BY CountBids
  6. PIVOT NumDays In ("1 Week", "2 Weeks","3 Weeks","4 Weeks", "30 days", "60 days", "90 days", "120 days", "150 days", "180 days", ">180 days");
  7.  
Jun 2 '07 #4
FOE2272
20
Thank You, Things are working fine.
Jun 4 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Thank You, Things are working fine.
You're welcome. Glad its working for you.

Mary
Jun 4 '07 #6

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

Similar topics

1
by: Heath | last post by:
I have serious Access problems so please be gentle. I have one table that stores the quantities and net sales for thousands of Products. I have another table that has fixed costs values on a...
1
by: laurenq uantrell | last post by:
I am trying to construct a query that sums sales by salespersons and only returns a list of salespersons that have a sum of sales lower than the previous month for whatever date rane is selected....
2
by: Carl | last post by:
Hi, I have a query that produces an output similar to the sample shown below. These records are based on certain criteria and a date range selected from a form. I need to create some kind of...
3
by: Wired Hosting News | last post by:
Lets say I have 10 products in 10 different stores and every week I get a report from each store telling me how many items they have left for each of the 10 products. So each week I enter in 100...
5
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed...
0
by: heidan | last post by:
Dear, I have a question of representing the relationship of sales invoice's posting date and post period into RDF. Let's say every sales invoice has a posting date which records when this...
1
by: josecruz | last post by:
I have created a main report, which is controlled with a date range parameter from the main form. The report has several sub reports, which perform calculations (counts and averages at the subreport...
1
by: Del | last post by:
I have a parameter query that requires the user to enter a Start Date: and End Date: and pull data between that date range. I am currently using the following parameter; Select * From mytable...
2
by: RZ15 | last post by:
Hi guys, I'm really drawing a blank here for how to deal with fiscal months in my monthly sales/receipts reports. My issue is that calculating the months is not as simple as saying 'if the invoice...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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
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...

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.