Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mean Distance ( How to avoid -ve numbers) 1

Status
Not open for further replies.

old123

MIS
Jun 1, 2005
31
US
Crystal report Ver 9
Database AS400

Existing Report

Iam trying to find mean distance between failure

Bus No WO no Mileage Differnce
9717 XXXXX 184049 0
9717 XXXXX 185723 1674
9717 XXXXX 186093 370
9717 189985 3892
9717 189987 2
9717 2637 -187350
9717 4492 1855
9717 4814 322
9717 9940 5126

Summary Count & Avg -2932.60

Differnce is calculated

IF {FM_300L2.FMASET} = PREVIOUS({FM_300L2.FMASET}) THEN
{FM_300L2.FMPMR}- PREVIOUS({FM_300L2.FMPMR})
ELSE
0

Avg Is calculated

whileprintingrecords;
numbervar summiles;
numbervar counter;
if counter > 0 then summiles/counter else 0

My results is coming incorrect because of my data , however i can't change that data as when we change the Hubmeter of a bus ( Odometer) it initialies back to 0.


Any suggestions

 
You could try:

IF {FM_300L2.FMASET} = PREVIOUS({FM_300L2.FMASET}) THEN
(
if {FM_300L2.FMPMR} > PREVIOUS({FM_300L2.FMPMR}) then
{FM_300L2.FMPMR}- PREVIOUS({FM_300L2.FMPMR}) else
{FM_300L2.FMPMR}
)
ELSE
0

-LB
 
Thanks , this worked......... I have alot to learn.
 
LB

I was looking at my results , it worked when the value is -ve however when the mileage is same for both the WO instead of giving differnce as 0 it returns the same value.

9717 XXXXX 184049 0
9717 XXXXX 185723 1674
9717 XXXXX 186093 370
9717 xxxxx 186093 0
9717 189985 3892
9717 189987 2
9717 2637 -187350
9717 4492 1855
9717 4814 322
9717 9940 5126

now it is displaying

9717 XXXXX 184049 0
9717 XXXXX 185723 1674
9717 XXXXX 186093 370
9717 xxxxx 186093 186093
9717 189985 3892
9717 189987 2
9717 2637 2637
9717 4492 1855
9717 4814 322
9717 9940 5126

 
I thought that was what made sense, i.e., I assumed that was the result you wanted. If the odometer was turned back to zero, and then 2637 more miles were added, why wouldn't you want to show the difference as 2637?

-LB
 
LB

It works fine when odometer was turned back to zero & then 2637 miles were added. Problem is when the mileage is same consecutively for 2 work orders then instead of differnce to be 0 it shows the meter reading

Below is the output

9717 XXXXX 184049 0
9717 XXXXX 185723 1674
9717 XXXXX 186093 370
9717 xxxxx 186093 186093

In this case last entry differnce should be 0. this mean the bus failure was within 0 miles.

I hope i make sense.


 
Oh, I see. Then change it to:

IF {FM_300L2.FMASET} = PREVIOUS({FM_300L2.FMASET}) THEN
(
if {FM_300L2.FMPMR} >= PREVIOUS({FM_300L2.FMPMR}) then
{FM_300L2.FMPMR}- PREVIOUS({FM_300L2.FMPMR}) else
{FM_300L2.FMPMR}
)
ELSE
0

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top