My formula won't sum in Crystal Reports

Posted on 2009-12-23
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 100

    Accepted Solution

    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

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    1. Set up your parameter at the report level as usual, check the box Multi-value, and set the Data Type to String 2. Set the Stored Procedure Parameter to varchar(max)  --<---- This part here is the key to it's success Example:    @cst_key var…
    I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now