Summarizing a Code-field

<< Click to Display Table of Contents >>

Navigation:  Introduction to Crystal Reports > Developing Own Crystal Reports >

Summarizing a Code-field

Introduction to Crystal Reports > Developing Own Crystal Reports

In the project we have used, Code C03 is the Vertical Moment. We would like to summarize the moments.

Crystal Reports can only summarize numerical fields. And since ShipWeight stores the code values as strings, you cannot summarize code values directly.

The solution is to create a formula that converts the string C03 into a numerical value.

Create a new formula named ‘VMom’. In the Formula Editor drag-and-drop the field ITEM.C03 into the editor.

To convert a string to a number, you need to use a Crystal-Reports function named TONUMBER(). The formula should look like this:



Now, the formula ‘VMom’ is available in the ‘Field Explorer’.

In the design area, select and delete the field ‘C03’. Then drag the formula ‘VMom’ into the report.

To insert a summary of the Vertical Moment, choose Insert Summary from the Insert menu.

Now the Insert Summary window will appear. First, select ‘VMom’ in the ‘Choose the field to summarize’ list box.

Then make sure the Calculate this summary option is set to ‘Sum’.

Finally, set ‘Summary Location’ to ‘Grand Total (Report Footer)’


In the same way, insert a Group summary. Hint: in the ‘Insert Summary’ window, you will need to set the ‘Summary location’ to ‘Group #1: ITEM.C01 – A’

Now, you successfully have inserted a summary of code values into your report. Click the Preview tab to see the result.