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

Find min and max for row of formulas

Status
Not open for further replies.

rhowle

IS-IT--Management
Jun 9, 2006
9
0
0
US
I need help finding the max and min for a row of formulas.

{Date} {trim1} {trim2} {trim3} {MIN}{MAX}{Total}
6/24/2009 0.80 0.57 0.63 ? ? 2.00
6/23/2009 1.03 0.74 0.63 ? ? 2.40

Each trim formula has this fix({@hr1},2)

I got the total to work by {trim1}+{trim2}+{trim3}

What I what the new formulas to show MIN=0.57 MAX=0.80 for given date 6/24 and MIN=0.63 MAX=1.03 for 6/23 etc.

I have tried everything I can think of hope someone can help.

Thanks
Robbie
 
Hi,
try 2 If..Then..Else formulas for MIN and MAX something like:
Code:
@Max
If ({trim1} > {trim2} and {trim1} > {trim3})
Then
{trim1}
Else
 If ({trim1} > {trim2} and {trim1} < {trim3}) and
    {trim3} > {trim2}
  Then
  [trim3]
Else
  ({trim1} < {trim2} and {trim1} > {trim3}) and
    {trim2} > {trim3}
 Then
  {trim2}

Use a similar approach for Min



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
not sure if this would be the best idea but here goes,

could you not use a conditional statement something like:

if {trim1} > {trim2} and {trim1} > {trim3} then {trim1}
else if {trim2} > {trim1} and {trim2} > {trim3} then {trim2}
else if {trim3} > {trim1} and {trim3} > {trim2} then {trim3}

just an idea
 
Thanks that got me on the right track, but what if the max value is = it prints out 0.00 I need to print out that value.
 
Hi,
Not sure what you mean by 'max value is ='

= to what?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Trim2 and Trim3 etc.

might equal each other on a certain date then they aren't > or < each other so 0.00 is printed. But I would need to print that value.

Say
Trim1 Trim2 Trim3 Trim4
0.23 0.53 0.53 0.45

I would want it to print 0.53 since it is the MAX
 
rhowle,

Using greengo204's solution (as all signs are the same), replacing these ">" with ">=" may resolve the issue.

Code:
IF ({trim1} >= {trim2} and {trim1} >= {trim3}) THEN {trim1}
else 
IF ({trim2} >= {trim1} and {trim2} >= {trim3}) THEN {trim2}
else 
IF ({trim3} >= {trim1} and {trim3} >= {trim2}) THEN {trim3}

Hope this helps.

Mike
___________________________
There Are 10 Types of People,
Those Who Can Read Binary...
And Those Who Can't.
 
That got it thanks for everybody's help now the masterpiece is finished.
 
You could simply use the following:

//{@min}:
minimum([{@trim1},{@trim2},{@trim3}])

//{@max}:
maximum([{@trim1},{@trim2},{@trim3}])

-LB
 
Hi,
As usual LB, you have found the Occam's Razor solution - I must remember to read the help section more...[blush]

By the way rhowle, you can check for the existance of a min or max value by using the HasUpperBound (x) and
HasLowerBound (x) functions to pre-test the set.




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top