Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Percentage calculation in expression of report
Message
From
30/11/2001 13:30:15
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00588031
Message ID:
00588163
Views:
38
Max --

You could go a couple ways.

My natural preference would be to calculate this before running the report, if you need it calculated once as the sum of the records.

In the report, substitute nmyTempPublicCalc for calls to Calcrpt().

Then couch your call to the report with this code.

PUBLIC nmyTempPublicCalc
CALCULATE SUM (Calcrpt()) FOR FilterUsedOnReport TO nmyTempPublicCalc

REPORT FORM ....

RELEASE nmyTempPublicCalc

There are more sophisticated ways of defining the scope of the variable, but this should get the job done. This is probably faster than the next option.

Another way would be to define a report variable MyCalc (or whatever). Check the "Sum" line in the Calculate box. Then, in Value to Store, put in Calcrpt(). Then, use the MyCalc variable in place of the function call. This is probably simpler than the first option.

HTH!

Jay


>Hi Jay,
>I think I know what I am doing wrong, the problem is how do I fix it! :)
>the calcrpt() is used for each row on the report so what I need is the sum of the calcrpt() which is done at the end of the report. How would I code for that? Something to the effect of the following?
>( SUM(calcrpt()) / ( SUM(calcrpt()) + myTable.field + myTable.field2 ) ) * 100
>
>Thanks again!
>Max
>
>
>> Max --
>
>> Nothing leaps to mind...
>
>> A couple areas:
>1. Test if it's a calculation issue.
>From what you describe, I think it would be easy to separate the function from the report and test to see with specific input if you're getting the output you expect.
>
>> SET DEFAULT TO (Drive\Path\PrgContainingCalcRpt)
>USE myTable
>GO TOP
>? ( calcrpt() / ( calcrpt() + myTable.field + myTable.field2 ) ) * 100
>
>> 2. Test if it's a display issue.
>If your denominator values are large, it's possible that the 2 decimal places you have defined for the report field won't display anything. Expand to a few more decimal places and see if you get some result.
>
>> Confirm that you have your display field set up appropriately.
>
>> HTH,
>
>> Jay
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform