Complex report with Advanced Matrix in FastReport .NET

Complex report with Advanced Matrix in FastReport .NET

This article continues the previous article, in which we looked at how to create a complex report. The report created in that article has become a source of inspiration for a new object - AdvancedMatrix.

The report in the previous article included three sections:

1) yearly statistics;
2) quarterly statistics;
3) monthly statistics.

A complex report of three matrices with intervals between matrices added for the sake of clarity

Each of the sections was implemented using a separate matrix, which had to be done due to the limitations of the standard MatrixObject. In the new version of FastReport .NET, we have added an updated version of this object, which is called AdvancedMatrix. It allows you to develop the entire report in one matrix. Let's see how to do it.

Add an AdvancedMatrix object to the empty data band:

Improved Matrix on data band

Let's remember what the data we use looks like:

Data window

For the simplest matrix, we need to drag three fields: country_name, fruit_type and amount.

Here's what the matrix looks like now:

Matrix in designer and preview

The new matrix allows you to change the calculations in the cells. In this case, we need the amount, but we can replace it with something from the following list:

Calculation functions

Let's remake the matrix. We need the fields country_name and fruit_type to be used in grouping — the report should group the list of fruits by country, and there should be a column for each individual year:

The Matrix in designer and preview, "year" field has been added

At this stage, we go beyond the capabilities of a regular MatrixObject. Let's add additional fields year and quarter to the matrix, and also replace empty values with zeros:

The Year and Quarter fields have been added to the matrix, they form a breakdown by quarters

What we previously had to do with two matrices can now be done with just one. Now we have a breakdown both by years and quarters. Let's go even further.

Breakdown by month was added

At this stage, we have a matrix with all the necessary data. To increase readability, we can change the display of the matrix and data.

First, let's merge the cells with the only text:

Multiple cells were selected, the "merge cells" option was selected in the cell context menu

A new menu for editing titles can help with displaying data:

Open Header Properties Editor

Now the matrix looks like this:

Matrix preview, text captions were added

Finally, we can compare the report preparation speed when it consists of three regular matrix objects and when it consists of one large matrix.

The test was done on a computer with an AMD Ryzen 5 3600 and 16GB of RAM. There are 5000 records displayed in the data table.

Attempt

3 matrices of MatrixObject

1 AdvancedMatrix

#1

906 ms

656 ms

#2

828 ms

625 ms

#3

937 ms

640 ms

#4

875 ms

641 ms

#5

891 ms

672 ms

#6

922 ms

656 ms

Average:

893.3 ms

648.3 ms

 

As you can see, preparation time drops by ~27% on average, which can save a lot of time on reports with many data.

In this article, we showed you how to recreate the report from the previous article. Advanced Matrix allows you to implement several useful features - for example, the TopN filter sort for selecting the 5 records with the highest calculated values.

You can learn about all the features of this object in our documentation.

Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.
Trustpilot