Creating A Report From An External Data Source
Creating A Report From An External Data Source
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
A data source is a facility for accessing data. You can use the predefined Dynamics AX data source, which connects to the Microsoft
Dynamics AX application database. Or, you can define an external data source to retrieve data from a different location. In this
walkthrough, you will create a report from data that is stored in a separate SQL database that you create. In your report model, you will
define an external data source that specifies the connection information for the database so that you can retrieve data from that
database to display in your report.
Creating a report
Prerequisites
To complete this walkthrough, you will need:
https://docs.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/walkthrough-creating-a-report-from-an-external-data-source 1/6
11/17/2020 Walkthrough: Creating a Report from an External Data Source | Microsoft Docs
2. When prompted to connect to a server, be sure to specify Database Engine for the Server type field and log in as a user who has
administrative privileges to create databases and tables for the SQL Server.
3. In SQL Server Management Studio, click New Query to display the query editor window.
SQL Copy
INSERT INTO Item VALUES (1983, 'Saw', 'Wooden Handle Saw', 7.89, 11.99, 1);
INSERT INTO Item VALUES (4920, 'Nails', '10 oz Flat Top Nails', 3.45, 4.99, 0);
INSERT INTO Item VALUES (6728, 'Screwdriver', 'Standard Screwdriver', 2.75, 3.99, 1);
INSERT INTO Item VALUES (9283, 'Nails', 'Roofing Nails 5 lbs', 12.45, 15.99, 0);
INSERT INTO Item VALUES (4829, 'Tape Measure', '25 foot Tape Measure', 12.87, 16.99, 2);
INSERT INTO Item VALUES (2893, 'Nails', 'Finish Nails', 3.90, 5.59, 1);
6. Verify that the database and table have been added to your server.
3. In the Installed Templates pane, click the Microsoft Dynamics AX node, and in the Templates pane, click Report Model.
5. Click OK.
database.
Property Value
Note
Insert the name of your SQL server for [YourServerName]. It must be the name of the SQL
server that contains the database that you created in the previous procedure. In this
statement, Security Support Provider Interface (SSPI) is using Microsoft Windows user
credentials for authentication. You may need to use a different authentication mode
depending upon how you have set up your SQL Server instance.
Name AXSampleData
Provider SQL
Creating a Report
https://docs.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/walkthrough-creating-a-report-from-an-external-data-source 4/6
11/17/2020 Walkthrough: Creating a Report from an External Data Source | Microsoft Docs
Next, you will create a report to display item data. You will start by creating a query for the report dataset using a Transact-SQL
statement. After you define the dataset, you will format the data. The status of an item is indicated by an integer value between 0 and 2.
The value 0 means that the item is In Stock. The value 1 means that the item is On Order. The value 2 means that the item is Back
Ordered. You will add an expression to the report to convert the integer value to a text representation so that it is easy to read. You will
also format the cost and selling prices as currency values. The following procedure explains how to create the report.
Property Value
Name Item
Query Select ItemID, Name, Description, Cost, SellingPrice, Status from Item
https://docs.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/walkthrough-creating-a-report-from-an-external-data-source 5/6
11/17/2020 Walkthrough: Creating a Report from an External Data Source | Microsoft Docs
8. In Model Editor, expand the Fields node for the Item dataset. Select the Cost node, and in the Properties window, set the Format
String property to Currency.
10. Drag the Item dataset onto the Designs node for the report. This creates an auto design for the report based on the data in the
dataset.
11. Expand the AutoDesign1 node, expand the node for the table definition, and then expand the Data node.
12. Select the Status node, and in the Properties window, click <Expression…> from the drop-down menu for
the Expression property.
The Edit Expression dialog box is displayed. In this dialog box, you will enter an expression so that text displays for the item status.
13. In the Edit Expression dialog box, type the following expression =Switch(Fields!Status.Value = 0, "In Stock", Fields!Status.Value = 1,
"On Order", Fields!Status.Value = 2, "Back Ordered"), and then click OK.
17. In Model Editor, expand the AutoDesign1 node, and then select the table definition node.
19. To preview the layout of the report, right-click the AutoDesign1 node, and then click Preview.
https://docs.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/walkthrough-creating-a-report-from-an-external-data-source 6/6