Thursday 15 September 2011

Reporting Services - Custom Sort Orders in Tables

SSRS allows you by default to sort on a value  either by A to Z or Z to A, which is fine for most scenarios however what happens if you want to sort in a specific way.

Example, you have 3 values and you want them sorted as per below:

Low
Medium
High

A to Z would give you

High
Low
Medium

Z to A would be a reverse so neither of these would achieve the required sort order.

The answer is so add a IFF Statement to the Sort Expression and select A to Z as the Order, so for example

=iif(value=”Low”,”1”, iif(value=”Medium”,”2”, iif(value=”High”,”3”,””)))
 
The order is then sorted on the numeric value as opposed to the Alphabetical value, thus giving you your desired sort order J

4 comments:

  1. Thank you.
    Need this.
    Stewart Anderson
    West Australian News

    ReplyDelete
  2. Instead of nesting IIF() functions, rather use the Switch() construct.

    =Switch(Fields!Field1.Value = "Low", 1,
    Fields!Field1.Value = "Medium", 2,
    Fields!Field1.Value = "High", 3)

    ReplyDelete
  3. Dave: very true, either way works.

    ReplyDelete
  4. Getting error The SortExpression.Value expression for the tablix ‘Tablix1’ contains an error: [BC30198] ')' expected.

    ReplyDelete

ADFS Timeout on Server 2012 for CRM 2011

This follows on from this Microsoft Guide http://social.technet.microsoft.com/wiki/contents/articles/7681.setting-the-adfs-timeout-for-crm...