My formula won't sum in Crystal Reports

Posted on 2009-12-23
Medium Priority
Last Modified: 2012-08-13
I have a formula that displays only the quantity from a customer's most recent order.  
Part 1:  Find the Max OrderNo for the customer. Using the Running Totals Fields it finds the max OrderNo and evaluates on Change of CustomerNo and resets on Group 2)
Part 2:  If OrderNo = MaxOrderNo then OrderQty else 0. Using Formula Fields with the MaxOrderNo derived from Part 1
Problem:  I need to sum the column of data created by my two part formula, but Crystal is not allowing a cummulative sum on the formula.  I need to sum both the group 2 and the report grand total. Thank you for any help
Question by:briankam
1 Comment
LVL 101

Accepted Solution

mlmcc earned 2000 total points
ID: 26115783
Maximum is a PrintTime formula and it is evaluated after summary functions are evaluated thus the formula isn't available for a summary.

Modify your formula

Global NumberVar GroupTotal;
Global NumberVar GrandTotal;
Local NumberVar Value;

If OrderNo = MaxOrderNo then
    Value := OrderQty
    Value := 0;

GroupTotal := GroupTotal + Value;
GrandTotal := GrandTotal + Value;

In the group header add a formula
Global NumberVar GroupTotal;
GroupTotal := 0;

In the main report header
Global NumberVar GroupTotal := 0;
Global NumberVar GrandTotal := 0;

To display them
Global NumberVar GroupTotal;

Global NumberVar GrandTotal ;


Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question