Search code examples
crystal-reports

Returning correct group label in footer


enter image description here

I want roll up the Amount Billed in the Details section by the first 5 characters in the Item column. So 01-00.00 becomes 01-00. I currently do this by grouping the Details by a Formula Field that grabs the left 5 characters the Item. So I wind up with a group footer that has the Item, Description, and the Amt Billed of 8000 (0 + 5000 + 0 + 3000).

But I cannot specify that I want the Description in my group footer to go with Item 01-00.00. Crystal chooses the Description for my group footer which goes with 01-00.03 because it's the last one in the list. How can I bring the correct description down?


Solution

  • Write suppressed formula to go in your Details section that looks something like:

    Shared StringVar myDesc;
    If Right({ItemNumber}, 2) = "00" Then
        myDesc := {Description}
    

    Keep in mind {ItemNumber} refers to the field in your table before you crop off the decimals. Then make a second formula in your group footer:

    Shared StringVar myDesc;
    myDesc
    

    Done correctly, the second variable will now display whichever Description had a corresponding ItemNumber that ended in .00 originally. This shouldn't be affected by the order in which items are displayed in your group.