Advanced SSRS Grouping and Page Breaks in Microsoft Dynamics AX 2012

When developing Microsoft Dynamics AX 2012 custom SSRS reports, developers may be required to display data within groups, for example, display budget control transactions by budget group.  In these scenarios, it may be required to display information within each group including a group header and subtotal. It may be required to display the group header for each new page, for example if the transactions for a group span multiple pages. It also may be required to allow users to select whether they want each new group to display on a new page.

This post will cover the following:

  • How to display an SSRS report with groupings and to display the grouping header and subtotal
  • How to print the group header for a new page, for examples if the number of transactions for a group span multiple pages
  • How to include an option to print a new page for each grouping

Advanced properties and code will be used to demonstrate the above. An included XPO project with a sample project for Microsoft Dynamics AX 2012 R3 will be included. A simple table control showing a pre-defined list of customer accounts with a subtotal and grouping by customer account.

 

The following describes how to configure the table to include groupings with a sample SSRS report included:

  • A sample report is included, as a starting point, a simple table control was added:

  • On the report table, add a parent group:

  • For this demonstration, we will include a header and footer to display the group headings and to print a sub total for the group:

  • The report table control should look like this:

  • Copy the first column headings to the new row, and delete the first row:

  • Click on advanced mode. This will allow us to print the groupings for each new page:

  • Set the groupings to print on each new page. If the number of transactions prints across multiple pages, the group heading will always print.

  • The left column can be deleted as it is not needed. The report should look like this now:

  • Formatting is added to the report, to add a grouping footer total for the amount column:

  • Running the report, we can see the groupings and totals:

  • The sample data in the report is increased so the data in the first group prints across multiple pages:

  • To force new grouping to print on a new page. Click on the AccountNumGroup and right click and select Group Properties. Set the Page Break option:

  • Each new group will print on a new page:

  • To control whether the groups print on a new page, a parameter was added to the report contract. Since Microsoft Dynamics AX 2012 SSRS reports do not allow expressions to be used to determine whether a page break occurs in a group, we must create 2 tables and hide the tables based on the new page parameter.
  • To hide the Tablix, right click on the Tablix properties and set the hidden properties:

  • Enter the following expression. This will be used to hide the table control if the ‘new page’ checkbox is not checked:
=iif(Parameters!ReportDS_NewPage.Value = 0, true, false)

  • Duplicate the table control, disable the page breaks for the AccountNum group, and enter the following as the expression for the Tablix visibility:
=iif(Parameters!ReportDS_NewPage.Value <> 0, true, false)

  • The end result should look like this. The new page checkbox when running the report will control which Tablix to print:

  • Try it yourself. Run the report included in this blog with and without the new page checkbox:

 

Let me know if you have any questions!

The post Advanced SSRS Grouping and Page Breaks in Microsoft Dynamics AX 2012 appeared first on Avantiico.

Related
Recommended