Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Preparing Data for Display in a Tablix Data Region

Preparing Data for Display in a Tablix Data Region

SQL Server 2008

A Tablix data region displays data from a dataset. You can view all the data retrieved for the dataset or you can create filters so that you see only a subset of the data. You can also add conditional expressions to fill in null values or modify the query for a dataset to include columns that define the sort order for an existing column.

Data for the field collection in a dataset includes all values retrieved from the data source at run time, including null values and blanks. Normally null values and blanks are indistinguishable. In most cases, this is the desired behavior. For example, Numeric aggregate functions like Sum and Avg ignore null values. For more information, see Using Built-in Report and Aggregate Functions in Expressions (Reporting Services).

If you do want to handle null values differently, you can use conditional expressions or custom code to substitute a custom value for the null value. For example, the following expression substitutes the text Null wherever a null value occurs in the field [Size].

=IIF(Fields!Size.Value IS NOTHING,"Null",Fields!Size.Value)

For more information about eliminating nulls in your data before retrieving the data from a SQL Server data source using Transact-SQL queries, see Null Values and Null Values and Joins.

Testing for null values in an expression is fine as long as the field itself exists in the query result set. From custom code, you can test whether the field itself is present in the collection fields returned from the data source at run time. For more information, see Using Dataset Fields Collection References in Expressions (Reporting Services).

By default, you can alphabetically sort values in a dataset field. To sort in a different order, you can add a new column to your dataset that defines the sort order you want in a data region. For example, to sort on the field [Color] and sort white and black items first, you can add a column [ColorSortOrder], shown in the following query:

SELECT ProductID, p.Name, Color,
      WHEN p.Color = 'White' THEN 1
      WHEN p.Color = 'Black' THEN 2
      WHEN p.Color = 'Blue' THEN 3
      WHEN p.Color = 'Yellow' THEN 4
      ELSE 5
   END As ColorSortOrder
FROM Production.Product p

To sort a table data region according to this sort order, set the sort expression on the detail group to =Fields!ColorSortOrder.Value. For more information, see How to: Sort Data in a Data Region (Reporting Services).

Community Additions

© 2015 Microsoft