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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with a median formula 2

Status
Not open for further replies.

AZdesertdog

IS-IT--Management
Dec 2, 2003
88
US
I have 4 summary formulas that I want to calculate the median on but the median function won't calculate my fields (error..these fields can not be summarized). I'm sure it would be easy to do it in a formula since there will always be just 4 values to compare. What I need to do is kick out the largest and smallest value and then average the two remaining values. Like this:

@val 1 75.19%
@val 2 69.93%
@val 3 76.24%
@val 4 77.82%

I would eliminate val 2 and val 4 (lo & hi ) and average vals 1 and 3 getting a median of 75.72%

Any help to get a formula to do this would be appreciated.
 
Please share the formula for {@val}--I'm assuming these are four different results of one formula.

-LB
 
Hey LB- Actually they're four entirely different formulas.

@var1 is:
(if {@Display}<> 0 then {@Display2}/{@Display})*100

@var2 is:
evaluateafter ({@displayAPP});
if (Sum ({@Charges}, {Header.InitialCreatePeriod}))<>0 then
((({@displayAPP}*{@Invoicecounts})/
(Sum ({@Charges}, {Header.InitialCreatePeriod})))*100) else 0

@var3 is:
(100-{@Hcontra%})

@var4 is:
100-{@Hcontra%trips}
 
The following might work, but it's hard to tell since we know nothing about what's in all the formulas within your formulas

numbervar x;
numbervar y;
numbervar max;
numbervar q;
numbervar k;
numbervar min;

if {@val1} > {@val2} then x := {@val1} else x := {@val2};
if {@val3} > {@val4} then y := {@val3} else y := {@val4};
if x > y then max := x else max := y;

if x <> {@val1} then q := {@val1} else q := {@val2};
if y <> {@val3} then k := {@val3} else k := {@val4};
if q < k then min := q else min := k;

({@val1}+{@val2}+{@val3}+{@val4}-max-min)/2;

-LB
 
Thanks LB- that was EXACTLY what I needed. I just couldn't formulate it in my tiny brain. I always appreciate your help! -JJP
 
way to go lb!

Howard Hammerman,
Crystal Training and Crystal Material
On-site and public classes
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
Another way to do this, following the same principle, would be to use an array like :

Local NumberVar Array Values := MakeArray ({@val1},{@val2},{@val3},{@val4});
(Values[1]+Values[2]+Values[3]+Values[4]-Minimum(Values)-Maximum(Values))/2

Reebo
UK

Please Note - Due to current economic forcast and budget constraints, the light at the end of the tunnel has been switched off. Thank you for your cooperation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top