How to: Use a Query in a Report
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
This topic explains how to retrieve data for a Microsoft Dynamics AX report by using an AX Query. An AX Query is a query defined in the AOT. In a Visual Studio reporting project for Microsoft Dynamics AX, you can define a report in a report model. You will define a dataset with properties that describe how the query will be used to access report data.
Retrieving Data by Using an AX Query
The following procedure describes how to retrieve data for a report by using an AX Query.
To retrieve data by using an Ax Query
In Visual Studio, create or open a project based on the Report template. In Solution Explorer, right-click the project, point to Add, and then click Report.
In Model Editor, right-click the new report, click Rename, and then give the report a name.
Right-click the Datasets node, and then click Add Dataset.
Select the node for the dataset.
In the Properties window, specify the following values.
Dynamics AX - The data source for the dataset must be set to Dynamics AX if you want to set the data source type to an AX Query.
Data Source Type
Query indicates you will bind the dataset to an AX Query.
The default data region type for the dataset. Specify a value for this property if you plan to use the dataset in an auto design report. For more information about data region types, see Report Data Region Overview.
Set the Dynamic Filters property to True to create dynamic filters on your report. A dynamic filter enables an end user to filter data in the tables in the dataset. When this value is True, a dataset parameter and report parameter will be created for the fields in the tables in the dataset. When the value is False, the dataset parameter and report parameter are created for the ranges that are set in the query. For more information about creating dynamic filters, see Adding Interactive Features to Reports.
Provide a name for the dataset.
Click the ellipsis button (…). A dialog box is displayed with the queries that are defined in the AOT. Select a query that accesses the data you want to use for the report and then click Next. Expand the field nodes and select fields, field groups, display methods and dimensions that you want to use on the report.
The following list describes the options in the Select Fields tab of the Select a Microsoft Dynamics AX Query window.
Fields - list of fields for each of the tables accessed by the query. Fields are defined for a table to identify the name and type of data.
Field Groups - list of field groups for each of the tables accessed by the query. Field groups are a grouping of fields for a table with similar characteristics or purposes, used to optimize the design of forms and reports.
Display Methods – list of display methods accessed by the query. A display method is treated like a field in a query, even though the display method is retrieving the data from a different table.
AX Dimensions – list of the dimensions accessed by the query. AX Dimensions – list of the dimensions accessed by the query. Dimensions are additional classifications defined in a table for financial, product, and cost attributes.
Next, you can drag the dataset onto the Designs node. An auto design named AutoDesign1 is created for the report. For the complete steps to create a report bound to an AX Query, see Walkthrough: Creating an Auto Design Report.