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

8.5 - Formulas

Status
Not open for further replies.

mrquest

Technical User
Sep 29, 2003
6
US
I have two formulas on a detail record, called A & B...very basic formulas. I need to take the greater of the 'Sum' of A or B (i.e. a Group) and then arrive at a report total of these values.

Any ideas on arriving at the report totals....

I am able to write formulas to display the greater of 'Sum" of A or B, but cannot then create any such sum of this value.
 
Your formula for the maximum at the group level, {@max}, should look something like this, substituting your own fields:

maximum([Sum ({table.A}, {table.groupfield}), Sum ({table.B}, {table.groupfield})])

Then you need two formulas to get the report total:

{@accumtotmax} to be placed in the group header or footer (whereever your group totals are):

whileprintingrecords;
numbervar totmax := totmax + {@max};

{@displaytotmax} to be placed in the report footer:
whileprintingrecords;
numbervar totmax;

-LB
 
Anotehr method would be to have running totals for A and B for the group. Then do a formula field
If Tot-A > Tot-B then Tot-A else Tot-B

Madawc Williams
East Anglia, Great Britain
 
Thanks for your help, so far....I applied the formula and got a message that says "The summary / running total field could not be created."

I believe that it is not possible to find the maximum or minimum of a group of records and to then display that value in Crystal, and then summarize or have running totals.
 
My earlier suggestion works. I tested it. Please try copying and pasting the maximum formula exactly and then substituting your own fields.

If this still doesn't work, please post the contents of your formulas here so we can troubleshoot. If "A" and "B" represent formulas, not fields, please post these formulas also--this could be the problem.

-LB
 
I am not getting the results I need....the scoop

The Table is called MLedger. I have the report groups of (Institution/SecType/CUSIP) so the lowest level group is CUSIP. For each record on MLedger, a Db column called, {MLedger.CurMktValue}, is split into to seperate fields on report, one being "Long" and the other "Short" and the formulas are very basic,

IIF ({MLedger.SUFlag} = "U", {MLedger.CurMktValue} ,0 )
IIF ({MLedger.SUFlag} = "S", {MLedger.CurMktValue} ,0 )

I then have a group summary which totals Long and short formulas above by CUSIP (lowest group level).

From these summaries, I need to find the greater of total long or short (by CUSIP) and produce this in a running total or report footer summary.

The example that you gave me perhaps needs further definition...here is the literal of your formula that is not giving the desired result.

maximum([Sum ({MLedger.CurMktValue}, {MLedger.CUSIP}, {MLedger.SUFlag} = "S"), Sum ({MLedger.CurMktValue}, {MLedger.CUSIP}, {MLedger.SUFlag} = "U")])

I am trying to add a condition and the sum can't be created...

Thanks


 
If {@A} =
IIF ({MLedger.SUFlag} = "U", {MLedger.CurMktValue} ,0 )

and if {@B} =
IIF ({MLedger.SUFlag} = "S", {MLedger.CurMktValue} ,0 )

...then the maximum formula {@max} should be:

maximum([Sum ({@A},{MLedger.CUSIP}), Sum({@B}, {Ledger.CUSIP})])

Then, as outlined above create these two formulas:

{@accumtotmax} to be placed in the group (CUSIP) header or footer (whereever your group totals are):

whileprintingrecords;
numbervar totmax := totmax + {@max};

{@displaytotmax} to be placed in the report footer:
whileprintingrecords;
numbervar totmax;

I tested this using IIF formulas and it works.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top