Crystal Reports Need to Group by Derived Date Range

后端 未结 4 1711
迷失自我
迷失自我 2020-12-18 06:58

Long time listner, first time caller. I\'m using Crystal Reports 2010.

I have daily trade information that I need to group together if the volume doesn\'t change. H

4条回答
  •  执念已碎
    2020-12-18 06:59

    I'd use the "X-2" suppression function to hide all but the last from each row, and Previous() and Next() to find the endpoints.

    Group by BegDate; suppressing the details and group footer sections.

    Create an {@UpdateCurrentBegDate} function somewhere in the group header

    WhilePrintingRecords;    
    Global DateVar CurrentBegDate;
    
    If PreviousIsNull({table.Volume}) or Previous({table.Volume}) <> {table.Volume}
        Then ( //We found a new range
            CurrentBegDate = {table.BegDate};
         );
    
    ""; //Display nothing on screen
    

    And a {@DisplayBegDate} function where you currently have BegDate being shown

    EvaluateAfter({@UpdateCurrentBegDate});
    Global DateVar CurrentBegDate;
    

    Go to the Section Expert and click "X-2" next to the Suppress option (for the group header section). This is the formula for there

    Not(NextIsNull({table.Volume}) or Next({table.Volume}) <> {table.Volume})
    

    If you need to do totals or other calculations, you would do it in the {@UpdateCurrentBegDate} function (and you'd want to change the name to {@UpdateCurrentValues} or something similar). You can also create a new function that checks the Next() information if you only want to change things when the group changes -- using the default totalling functions will include the hidden values.

提交回复
热议问题