Search code examples
crystal-reports

Crystal Reports Conditional Grouping on Unrelated DB Field


I have some data in table SSTemp like this ("..." indicates data omitted for readability):

Month      Year      Number      Gross      Net
1          2013      1           1,000      500
2          2013      1           1,000      500
...
12         2013      1           1,000      500
1          2014      1           1,000      500
2          2014      1           1,000      500
...
12         2014      1           1,000      500
1          2015      1           1,000      500
...
12         2015      1           1,000      500    

I am new to Crystal Reports and am using version 8 (no, we can't upgrade). I want to roll up the totals for all line items in years past and leave the data as-is for the current year in the same report. Database field {CONTROLFILE.CURRENTYEAR} contains the current bookkeeping year for our system which is vital to determine the rollup groups. The CONTROLFILE table contains general settings for the system and has no data in it useful for JOINing, however I need to consider CURRENTYEAR for the grouping. The MONTH column should be blank on the summary lines, and indicate month on the current year lines. The end result data should look like this:

Month      Year      Number      Gross      Net
           2013      12          12,000     6,000
           2014      12          12,000     6,000
1          2015      1           1,000      500
2          2015      1           1,000      500
...
12         2015      1           1,000      500

Any suggestions would be most appreciated!


Solution

  • Use sub report concept.

    In main report calculate for previous years in sub report calculate for current year.

    In main report group by year And suppress details show summary in group footer in another group footer section place sub report and just place data in detail part don't group