Dynamics AX 2009: Business Intelligence – the Matrix Layout for Auto Design reports
Previously with Auto Design layouts, I left off with by saying that some required us to tweak the Datasets to get them to work. In this post, we’ll change the properties of the datasets and see how that enables the Matrix and chart layouts.
First, we need more data. I’ve revised the my Data Method to return more patient data …
using System;
using System.Collections.Generic;
using System.Security.Permissions;
using System.Data;
using System.Linq;
using Microsoft.Dynamics.Framework.Reports;
public partial class Report1
{
[DataMethod(), AxSessionPermission(SecurityAction.Assert)]
public static System.Data.DataTable DataMethod_Patient_Data()
{
int max_age = 60;
int min_age = 18;
int min_weight = 140; // weight in pounds
int max_weight = 240;
var areas = new[] { "Thoracic Surgery", "Emergency", "ENT" };
var doctors = new [] { "Reddy", "Jackson", "Tordilla" };
var r = new System.Random();
var names = new string[] { "Akuma", "Ryu", "Ken",
"Guile", "M.Bison" ,
"Chun-Li", "Cammy" ,
"Blanka", "E.Honda",
"Gen", "Birdie", "Adon",
"Sagat", "Dhalsim", "Zangief",
"Balrog", "Vega"};
var records = from name in names
select new
{
Name = name,
Age = r.Next(min_age, max_age),
Weight = r.Next(min_weight, max_weight),
Area = areas[ r.Next(0, areas.Length) ],
Doctor = doctors [ r.Next(0, doctors.Length)] ,
Hypertension = (r.NextDouble() > 0.9) ? true : false,
Diabetes = (r.NextDouble() > 0.85) ? true : false,
Asthma = (r.NextDouble() > 0.75) ? true : false
};
var datatable = Isotope.Data.DataUtil.DataTableFromEnumerable(records);
return datatable;
}
}
And then create a Data set that uses this Data method …
And when I drag it into the Designs node a new Design is created which I renamed to AutoDesign_Table_0 and set the styles for the layout and the table. The results are this.
Instead of modifying that Data set we will duplicate it using Copy

And then Paste
Which created this Dataset
And I will rename this to “Dataset_PatientData_1”
And set the Default layout to Matrix
And now drag it into the Designs node. A new AutoDesign is created. When you try to preview the design …
Obviously something is missing … let’s focus on the errors.
We obviously need to set something.
For this report, let’s say we want have a question about the number patients, we want to know who is treating them and what these patients are doing at the hospital.
In other words we want a matrix like this …
Go back to the dataset, click on Doctor and look at the properties for the field
The Grouping Type is set to category which is what we want
But the Field Type is set to Data. This we want to change.
We’ll set it to Grouping
OK, now the Doctor field is set up correctly.
After this modification, If we try to drag the dataset into a design and preview we’ll see …
This is better, now there’s only one error …
We are still missing column groupings.
We wanted the columns to be by “Area”, so let’s go to that field in the Data set
And examine it’s properties. Grouping Type is set to Category - we want to change this to Series
And Field type is set to Data. We’ll change this to Grouping.
Now the data set is ready.
Drag the dataset on to the Designs node and preview …
At least preview works.
But we need to fix this - we don’t want to see all the patient information, just the number of patients.
A simple way of fixing this up is expand the newly-created design
And then remove the data fields we don’t care about – just leave the Name field
If we drag preview the design now we will see …
Which is better.
Now we want to see the numbers of distinct patients, not their names.
So field the name field in the design.
And examine its properties. We are going to focus on the Aggregate Function from None …
to CountDistinct…
Now preview the report …
Almost what we want. But it looks ugly. Let’s set the style templates and see what happens.
Almost done.
Now we want to get rid of the “Name” on each column though.
Let’s look at the Name field in the design
And examine its properties. We will change it’s Caption property
by removing the expression and leaving it blank
Now preview the report…
Done.
SOURCE CODE
You can get it here: http://cid-19ec39cb500669d8.skydrive.live.com/browse.aspx/Public/Dev/SampleCode/Dynamics/SaveenR-Blog-Post-%7C52009-07-29%7C6?view=details