The extensive ActiveReports 7 API allows developers to completely control the report processing engine to fit their needs. Along with the simplicity of the design that allows the data to pass through quickly from processing to rendering, it provides the ability to present the report data in grouped format. Whether you need a simple listing or need a grouped view, ActiveReports is the solution. Basically, grouping refers to the segregation of data on the basis of a particular field of your data source. In a Section Report, data is grouped in the order in which it is fetched inside the raw form. Therefore, for best results, while setting the SQL query in your report data source, order the data by the grouping field. For example, SELECT * FROM Customers ORDER BY Country. In case you have any doubt in implementing grouping in your report, you can take a look here. Most often the users come with an issue: “what if I have some data in table with DateTime format and I want to group my data by month or year?” In this blog, I look to answer this query which is frequently asked by our customers. Solution to this problem is an easy task for the flexible ActiveReports engine. Following steps summarizes the solution.
- Add two Group headers/footers sections to the report.
- Assign the expressions in the 'DataField' property of these GroupHeaders that needs to show the data based on a year or month in a date. For the first Group header, assign its DataField property to something like ‘OrderDate.Year’ whereas the said property of the nested group would be assigned to the month : ‘OrderDate.Month’.
- This way, we would be first grouping the data year wise and then on the basis of months in that particular year.
Screenshot shows the final output of the implementation. Attached report file implements the above explained approach. You would need to load the RPX in the EndUserDesigner and it should give you the discussed output. In case you face any issues in loading the attached RPX file, you may go through this link RPX File