Monday, 14 March 2011

Calculations and Formulas with Conditions in Crystal Report

A short post this time continuing with the Crystal Reports issues. This time I'm going to focus on doing calculations within the formula workshop, in particular with conditional uses.
1. From your crystal report, expand Unbound Fields in the Field Explorer.
2. Select Number from Unbound Fields and drag it to the position you require on your Crystal Report.
3. When the Unbound Number has been placed on your report, right click and select 'Edit Formula'.
4. Then follow the code below to create a percentage calculation based on two boolean true/false conditions:
Shared numberVar MyCount;

{Field 1 Selected from Report Field Window} = true
{Field 2 Selected from Report Field Window} = false
MyCount := MyCount + 1
MyCount := MyCount;

MyCount/count({Field 3 Selected from Report Field Window})*100 & '%'
You can alter this code to your needs but hopefully it will give a broad understanding of a calculation done within Crystal Reports on data already called to the report.

No comments:

Post a Comment