You are on page 1of 4

Walkthrough1: Creating a Matrix Report

In this walkthrough, you will create a report to display customer transaction data in a matrix data region. A
matrix data region displays data in a two-dimensional grid of columns and rows that intersect at specific
data points. When defining a matrix data region, you can specify column and row groupings. The data
that appears in the detail cells are aggregates based on the intersections of columns and rows.

This walkthrough illustrates the following tasks:

 Defining a query
 Creating a reporting project
 Creating a report with a matrix data region

Prerequisites

To complete this walkthrough, you will need:

 Microsoft Dynamics AX with sample data

Note

This walkthrough uses the CustTable, CustTrans, and CustGroup tables. In order to view
data in the report, these tables must be populated with data.

 Microsoft Visual Studio 2010


 Microsoft Dynamics AX tools for Microsoft Visual Studio

Defining a Query

There are several ways to retrieve data for reports. In this walkthrough, you will use a query that is defined
in the Microsoft Dynamics AX development workspace. The following procedure explains how to define
the query that will be used to retrieve customer transaction data.

To define a query

1. Open Microsoft Dynamics AX.


2. In the AOT, right-click the Queries node, and then click New Query.
3. Right-click the node for the query, click Rename, and then type CustTransactions.
4. Expand the CustTransactions query.
5. Right-click the Data Dictionary node, and then click Open New Window.

1
Source: http://msdn.microsoft.com/en-us/library/cc623805.aspx
6. In the new window, expand the Tables node.
7. Locate the CustTable table and drag it onto the Data Sources node for the query.
8. Expand the node for the CustTable data source.
9. Select the Fields node, in the Properties window, set the Dynamic property to Yes.
10. Locate the CustTrans table and drag it onto the Data Sources node located below
the CustTable data source.
11. Expand the node for the CustTrans data source.
12. Select the Fields node, in the Properties window, set the Dynamic property to Yes.
13. Locate the CustGroup table and drag it onto the Data Sources node located below
the CustTrans data source.
14. Expand the node for the CustGroup data source.
15. Select the Fields node, in the Properties window, set the Dynamic property to Yes.
16. Right-click the Relations node for the CustTrans data source, and then click New Relation.
17. Select the node for the relation and specify the following values in the Properties window.

Property Value
JoinDataSource CustTable_1

Field AccountNum

Related Field AccountNum

18. Expand the node for the CustGroup data source.


19. Right-click the Relations node for the CustGroup data source, and then click New Relation.
20. Select the node for the relation and specify the following values in the Properties window.

Property Value
JoinDataSource CustTable_1

Field CustGroup

Related Field CustGroup

21. Save the query.

Creating a Reporting Project

Next, you will create a reporting project. When you create a Microsoft Dynamics AX project in Microsoft
Visual Studio, you can decide from two project templates: Report Model and EP Web Application. In this
walkthrough, you will use the Report Model template. This will give you access to several predefined
layout and style templates that you will use to define the layout of your reports. These templates are the
standard templates for Microsoft Dynamics AX reports.
To create a reporting project

1. Open Microsoft Visual Studio.


2. On the File menu, point to New and then click Project. The New Project dialog box is displayed.
3. In the Installed Templates pane, click the Microsoft Dynamics AX node. In the Templates pane,
clickReport Model.
4. In the Name box, type SampleMatrixReport, and in the Location box, type a location.
5. Click OK.

Creating a Report with a Matrix Data Region

Next, in the reporting project, you will create a report that displays customer transaction data in a matrix
data region. You will define a column grouping based on the TransDate field and two row groupings
based on theName and AccountNum fields. The following procedure explains how to create the report.

To create a report with a matrix data region

1. In Solution Explorer, right-click the project, point to Add, and then click Report.
2. In Model Editor, right-click the Report1 node and then click Rename.
3. Type SampleMatrixReport as the name.
4. Right-click the Datasets node for the report, and then click Add Dataset.
5. Select the node for the dataset.
6. In the Properties window, specify the following property values.

Property Value
Data Dynamics AX
Source

Data Query
Source
Type

Default Matrix
Layout

Name CustTransactions

Query Click the ellipsis button (…). A dialog box displays where you can select a
query that is defined in the AOT and identify the fields that you want to use.
Select the CustTransactionsquery and then click Next. Expand the All
Fields node for CustTable. Select theAccountNum field from
the CustTable table. Expand the CustTrans > All Fields node, select
the AmountMST and TransDate fields from the CustTrans table. Expand
theCustGroup > All Fields node, select the Name field from
the CustGroup table.

7. In Model Editor, select the Datasets > CustTransactions > Fields > AmountMST node.
8. In the Properties window, set the Aggregate Function property to Sum and set the Format
Stringproperty to Currency.
9. In Model Editor, drag the CustTransactions node onto the Designs node. An auto design
namedAutoDesign1 is created for the report.
10. Expand the AutoDesign1 node, expand the node for the matrix data region, and then expand
the Datanode.
11. Drag the TransDate field from the Data node onto the Column Groupings node.
12. Select the TransDate node.
13. In the Properties window, type the expression =Year(Fields!TransDate.Value) for
the Label property.
14. In Model Editor, expand the TransDate node, expand the Group on node, and then select
theTransDate node that is located below the Group on node.
15. In the Properties window, type the expression =Year(Fields!TransDate.Value) for
the Expressionproperty.
16. In Model Editor, drag the Name field from the Data node onto the Row Groupings node.
17. Select the Name node.
18. In the Properties window, set the Display Width property to 1in and set the Display
Subtotals property to False.
19. In Model Editor, drag the AccountNum field from the Data node onto the Row Groupings node.
20. Select the AccountNum node.
21. In the Properties window, set the Display Width property to 1in and set the Display
Subtotals property to False.
22. In Model Editor, select the AmountMST node that is located below the Data node.
23. In the Properties window, set the Display Width property to 1in, and set the Text
Align property toRight.

To apply layout and style templates

1. In Model Editor, select the AutoDesign1 node.


2. In the Properties window, set the Layout Template property to ReportLayoutStyleTemplate.
Also, type Customer transactions for the Title property.
3. In Model Editor, expand the AutoDesign1 node, and then select the node for the matrix data
region.
4. In the Properties window, set the Style Template property to MatrixStyleTemplate. Also, delete
the default text for the Title property so that it does not display a title for the data region.
5. In Model Editor, right-click the AutoDesign1 node, and then click Preview.
6. Close the Preview window.

You might also like