Solved

Best way to average

Posted on 2006-10-30
9
324 Views
Last Modified: 2008-03-10
Crystal Reports XI

I have a report that goes from month to date.  There is a field I need to average, so how would I average quantity sold.
Example
Its October 12th
Oct 1 to 7th - 20 sold
Oct 8 to 12th - 10 sold
So the average should be 15 a week.
0
Comment
Question by:ThomasBallardIT
  • 4
  • 4
9 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 17835837
Hi ThomasBallardIT,
How are you defining a week?
1-7, 8-14, 15-21 etc?
or some other way?

Pete
0
 
LVL 3

Author Comment

by:ThomasBallardIT
ID: 17836007
Yes I would be defining a week as 7 days.  The way it is setup now, is that I pick a date and use the "month to date" thingamuhbob.  So I could pick Oct 2nd or Oct 29th or any day and I need it to be averaged in that manner.

Example
If I picked oct 2nd   - 5 sold for the month     Average would be 5
If I picked Oct 25th  - 90 sold for the month   Average would be 22
If I picked Oct 15th  - 50 sold for the month.  Average would be 25
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 125 total points
ID: 17836101
How do you define the week?

In case 3 - Oct 15 you have 2 weeks
In case 2 - Oct 25 you have 4 weeks

I think you need to ise some kind of test like

IF (Day({?YourDate}) <= 10) then
  TotalSold
ELSE IF (Day({?YourDate}) <= 17) then
  TotalSold \ 2
ELSE IF (Day({?YourDate}) <= 24) then
  TotalSold \ 3
ELSE
  TotalSold \ 4

mlmcc
0
 
LVL 3

Author Comment

by:ThomasBallardIT
ID: 17836341
This is what I got but I need a date-time field?


if {InvMovements.EntryDate} <= 8 then {InvWarehouse.MtdQtySold}
else
if  {InvMovements.EntryDate} <=15 then {InvWarehouse.MtdQtySold} / 2
else
if  {InvMovements.EntryDate} <=23 then {InvWarehouse.MtdQtySold} / 3
else
{InvWarehouse.MtdQtySold} / 4
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 100

Expert Comment

by:mlmcc
ID: 17836972
The DAY function will pull the Day value out of the DateTime field.

if  Day({InvMovements.EntryDate}) <= 8 then {InvWarehouse.MtdQtySold}
else
if  Day({InvMovements.EntryDate}) <=15 then {InvWarehouse.MtdQtySold} / 2
else
if  Day({InvMovements.EntryDate}) <=23 then {InvWarehouse.MtdQtySold} / 3
else
{InvWarehouse.MtdQtySold} / 4

mlmcc
0
 
LVL 3

Author Comment

by:ThomasBallardIT
ID: 17837142
It appears to be working for the most part, but there a few not dividing by anything when in this case they should all be dividing by 4.



if  Day({InvWarehouse.DateLastPurchase}) <= 8 then {InvWarehouse.MtdQtySold} / 1
else
if  Day({InvWarehouse.DateLastPurchase}) <=15 then {InvWarehouse.MtdQtySold} / 2
else
if  Day({InvWarehouse.DateLastPurchase}) <=23 then {InvWarehouse.MtdQtySold} / 3
else
{InvWarehouse.MtdQtySold} / 4
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 17837193
Could you have some NULL dates?  or bad date fields?

mlmcc
0
 
LVL 3

Author Comment

by:ThomasBallardIT
ID: 17837227
I figured it out

if day(maximum({InvWarehouse.DateLastPurchase})) <= 8 then {InvWarehouse.MtdQtySold} / 1
else
if  day(maximum({InvWarehouse.DateLastPurchase})) <=15 then {InvWarehouse.MtdQtySold} / 2
else
if  day(maximum({InvWarehouse.DateLastPurchase})) <=23 then {InvWarehouse.MtdQtySold} / 3
else
{InvWarehouse.MtdQtySold} / 4

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 17837730
Glad i could help

mlmcc
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now