





















































(For more resources related to this topic, see here.)
A matrix is an interesting representation format with a two-dimensional view of the data, allowing capabilities to consolidate by row and column. This recipe will discuss how to add and use a matrix data region in reports. Also discussed is the totaling capabilities in matrix reports.
This recipe is broken down into two sections. In the basic report design section we will build a simple RDP that will be used in this recipe as well as in other recipes found in this article and the actual recipe is in the second section.
This RDP can be time consuming if you have a huge database of sales orders, so limit your data to certain item groups or a certain period as required in the RDP's processReport method.
The general approach for analysis like this is to use OLAP so that it is faster and provides multiple dimensions of consolidations but using an OLAP to demonstrate these report controls might stop several from practicing. This is because the majority of AX developers are not BI experts. Keeping this in mind this RDP has been used to demonstrate the examples.
[ //bind query - shows in the report dialog SRSReportQueryAttribute(queryStr(PktSalesLine)) ] class PktItemSalesHistoryDP extends SRSReportDataProviderBase { PktItemSalesHistoryTmp salesHistoryTmp; } [ SRSReportDataSetAttribute(tableStr(PktItemSalesHistoryTmp)) ] public PktItemSalesHistoryTmp getItemSalesHistoryTmp() { select salesHistoryTmp; return salesHistoryTmp; } private void insertTmpTable(SalesLine _salesLine) { Qty qty; date shipDate; InventItemGroupItem groupItem; qty = _salesLine.QtyOrdered; shipDate = _salesLine.ShippingDateConfirmed; groupItem = InventItemGroupItem::findByItemIdLegalEntity( _salesLine.ItemId, _salesLine.DataAreaId); salesHistoryTmp.clear(); salesHistoryTmp.ItemId = _salesLine.ItemId; salesHistoryTmp.ItemGroupId = groupItem.ItemGroupId; salesHistoryTmp.Price = _salesLine.salesPrice; salesHistoryTmp.Amount = _salesLine.SalesPrice * Qty; salesHistoryTmp.Qty = qty; salesHistoryTmp.Year = year(shipDate); salesHistoryTmp.MonthOfYearId = mthOfYr(shipDate); salesHistoryTmp.Days = dayOfMth(shipDate); salesHistoryTmp.insert(); } [ SysEntryPointAttribute(false) ] public void processReport() { Query query; QueryRun queryRun; SalesLine salesLine; InventItemGroupItem itemGroup; query = this.parmQuery(); queryRun = new queryRun(query); while (queryRun.next()) { salesLine = queryRun.get(tableNum(salesLine)); this.insertTmpTable(salesLine); } }
A matrix data region is actually a Tablix control behind the hood. The Tablix control combines the behavior of table, list, and matrix reports. Though the UI has table, matrix, and list controls, they are the same controls under the hood; they open up with a different configuration. The matrix data region has both row and column group, whereas a table control has only column group. Matrix helps create summary type reports.