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