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

median value of 3 fields 2

Status
Not open for further replies.

kimchavis

Technical User
Jan 7, 2004
66
US
I have three fields fico1, fico2, fico3

I want the median value of these three fields. If fico1 =600 fico2=700 and fico3=675 i would want to return 675 in a formula. I am using cr10, and for the life of me cannot figure this out, im sure it is super simple. I found where this can be done in one field as a summary, but not as a calculation in the details section based on 3 fields. Please help.

Thanks,
Kim
 
There might be an easier way to do this, but I think the following works, if there are always three fields:

numbervar array x := [{table.fico1},{table.fico2},{table.fico3}];
numbervar i;
numbervar j:= ubound(x);
numbervar minx := 0;
numbervar maxx := 0;
numbervar medx := 0;

for i := 1 to j do(
if x = minimum(x) then
minx := x;
if x = maximum(x) then
maxx := x;
if minx = maxx then
medx := minx else
if x > minx and
x < maxx then
medx := x else
if x > minx and
x = maxx then
medx := maxx
);
medx

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top