Search code examples
c#.netcrystal-reports

Crystal Reports: using records outside Selection Formula


I'm not sure if I'm approaching this problem the right way.

I'm developing in C# .NET. I have a report with a date range Selection Formula, and I need to make a total sum of records to display in the report from the first day of the calendar year to the "from date". For example, if the report parameters are 21/05/2018 - 13/09/2018, I need to make a total of the records from 01/01/2018 to 20/05/2018.

Is there a way to solve this? Thanks!


Solution

  • One option is to select records from the first of the year and use the date range from the parameters to create a conditional total. I prefer to do this by creating a detail level formula that returns the value to be summed if the date falls within the date range criterion and zero otherwise. You can then simply sum that formula to get the conditional total.

    Another option is to use a subreport for the YTD data and pass the YTD total from the subreport to the main report via a shared variable.

    While there are other options, the ones above probably deserve first consideration.