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

Maximum from Multiple Fields

Status
Not open for further replies.

scott1971

Technical User
Apr 20, 2005
125
0
0
EU
Guys,

First off, apologies for posting this at the end of a similar thread, my error, bit frazzled yesterday,Anyway....
using Crystal XI and I need to get a maximum out of multiple fields.

My fields are located in GH3 and I have 5 fields though it is quite probable that not all will be completed.

My fields are as follows:

{proc1} {procamt1)
{proc2} {procamt2)
{proc3} {procamt3)
{proc4} {procamt4)
{proc5} {procamt5)

What I need to show is the Maximum amount from fields {procamt1} through {procamt5} and show that amount AND the relevant {proc1} through {proc5} field. I then want to be able to work out that maximum field + 25% or 40% dependant on another formula I have in this heading.

sorry, there's a lot in there but I'm stumped as how to do this. Hoping the +25% will be easy enough but I need that maximum before I can work that out.

Cheers

Scott
 
The maximum of the 5 fields on a given record is this:

Maximum({procamt1),{procamt2),{procamt3),{procamt4),{procamt5))

Or do you want 5 maximums, one for each of the {procamtX) fields?



Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
dgillz,

This didn't work, it tells me there are too many arguments. The data here is odd, I had to bring the same file over 5 times so as I could join it correctly, to be honest I'm not 100% sure that it will work doing that but it's the only way I could get the 5 proc fields to join to the 1 procamt field. Basically on our database I have file X with 5 fields and another file Y that holds the amounts but there is only 1 field in File Y as the data on that one field is relevant to all 5 fields in File X.

Any ideas as I'm totally lost?

Cheers

Scott
 
Not sure if this would then do the trick?

//{@ShowProc}
if Maximum({procamt1},{procamt2},{procamt3},{procamt4},{procamt5}) = {procamt1} then {proc1} else
if Maximum(({procamt1},{procamt2},{procamt3},{procamt4},{procamt5}) = {procamt2} then {proc2} else
if Maximum({procamt1},{procamt2},{procamt3},{procamt4},{procamt5}) = {procamt3} then {proc3} else
if Maximum({procamt1},{procamt2},{procamt3},{procamt4},{procamt5}) = {procamt4} then {proc4} else
if Maximum({procamt1},{procamt2},{procamt3},{procamt4},{procamt5}) = {procamt5} then {proc5}

//{@Addpercentage}
if {@formula1} = x then Maximum({procamt1},{procamt},{procamt3},{procamt4},{procamt5}) * 1.25 else
if {@formula1} = y then Maximum({procamt1},{procamt},{procamt3},{procamt4},{procamt5}) * 1.4 else

You could make the end result a text field showing all of this as a single string or keep them as seperate components for later use as values. Up to you.

'J
 
CR85user,

Again, like dgillz I can see that this should work but I think the problem is in the join of my files. I'm getting the same error message that too many arguments have been given and I'm sure it has to do with the joins.

Cheers

Scott
 
Where are you placing this formula?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
I can't even get to placing the formula, it won't let me exit from the formula correctly as it's returning this error.

Cheers

Scott
 
OK slight syntax change,this will work, I just tested it:

Maximum([red][[/red]{procamt1),{procamt2),{procamt3),{procamt4),{procamt5)[red]][/red])

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
Once again you have come up trumps, thanks again for your help though I fear I may be back before this report is completed, trying to replicate an AS400 report in Crystal is easier said than done I'm finding.

Thanks again to you and to CR85User
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top