Matrix Report Item


The Matrix report item is also known as a cross-tab or pivot table. Matrix is capable of having a dynamic number of rows and columns and expands row by row and column by column. Matrix can act like a Table (fixed columns, dynamic rows) or like a pivot table (fixed rows, dynamic columns ) to transpose data ( turn rows into columns of data). Matrix allows you to group and sort rows and columns of data and can have multiple groups of rows or columns.

Just like a table, each cell in a matrix contains a text box by default. Matrix also requires at least one row and one column group. Because of this requirement, the RDL of a matrix carries a <Grouping> section:

 <Grouping Name="matrix1_RowGroup1">     <GroupExpressions>        <GroupExpression />     </GroupExpressions>  </Grouping> 

This book uses a {GROUPING:{expression}} shortcut to abbreviate the appearance of this RDL. In turn, the {GROUPING} section is included in <RowGroupings> or <ColumnGrouping> sections, such as

 <RowGroupings>               <ColumnGroupings>      <RowGrouping>                 <ColumnGrouping>        <Width>1in</Width>        <Height>0.25in</Height>         <DynamicRows>                  <DynamicColumns>          {GROUPING}                            {GROUPING}          {ITEMS}                               {ITEMS}       </DynamicRows>                  </DynamicColumns>     </RowGrouping>                  </ColumnGrouping>   </RowGroupings>               </ColumnGroupings> 

Later in the book, <RowGroupings> and <ColumnGroupings> sections are abbreviated as {ROWGROUPINGS} and {COLUMNGROUPINGS} , respectively.

A simple matrix carries the following RDL. Note that DataSetName is for data regions during runtime.

 <Matrix Name="matrix1">  {POSITION}   <MatrixColumns>       <MatrixColumn>          <Width>1in</Width>       </MatrixColumn>     </MatrixColumns>    {ROWGROUPINGS}    {COLUMNGROUPINGS}    <DataSetName>DataSet1</DataSetName>    <Corner>      {ITEMS}    </Corner>    <MatrixRows>      <MatrixRow>        <Height>0.25in</Height>        <MatrixCells>         <MatrixCell>           {ITEMS}         </MatrixCell>      </MatrixCells>    </MatrixRow>   </MatrixRows>   </Matrix> 

Figure 11.8 demonstrates the design-time view of a matrix.

Figure 11.8. Design-time picture of a matrix.

You should note a couple of items related to Figure 11.8 (this book provides additional information on grouping in Chapter 12):

  • To create a subtotal for each group, right-click on a group header (row or column) and select Subtotal from the shortcut menu. Use the same menu to toggle Subtotal on and off.

  • A static group is created by using constant as a grouping expression.

  • To create a static row header, you can place a Rectangle item in the corner of the matrix and lay out some text boxes inside.

  • To properly color the entire Subtotal row, you can use the following expression in the BackgroundColor property of the Detail cell. This book provides more information about the InScope() function in Chapter 12.

 =IIF(Not InScope("matrix2_RowGroup1"), "LightGrey", "White") 



Microsoft SQL Server 2005 Reporting Services
Microsoft SQL Server 2005 Reporting Services
ISBN: 0672327996
EAN: 2147483647
Year: 2004
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net