Search code examples
ssrs-2008reportingservices-2005reporting-services

Custom Sorting in Matrix report on particular column


I have created a matrix report. I have a column 'Model' and values are (Classic, semi classic, Grand, twin , full, king , queen). Requirement was to split these values in columns.

I created column group for that and write expression like that:

=Switch(Fields!model.Value = "   ", "NULL" ,
    Fields!model.Value = "classic", 1, 
    Fields!model.Value = "semi classic", 1,
    Fields!model.Value = "Grand", 1,
    Fields!model.Value = "Twin", 1,
    Fields!model.Value = "Full", 1,
    Fields!model.Value = "King", 1,
    Fields!model.Value = "Queen", 1
)

Now I have to sort these models into particular order ( not in A-Z or Z-A).

order should be : twin, Grand, Queen, Classic , Full, semi classic, king

Can some one help me in this how to twist expression or some property.

Thanks


Solution

  • You've got most of this already written. If you set the Sorting to this expression, I think you'll get what you want.

    =Switch(
     Fields!model.Value = " ", 100 ,
     Fields!model.Value = "classic", 4,
     Fields!model.Value = "semi classic", 6,
     Fields!model.Value = "Grand", 2,
     Fields!model.Value = "Twin", 1,
     Fields!model.Value = "Full", 5,
     Fields!model.Value = "King", 7,
     Fields!model.Value = "Queen", 3)
    

    Use the expression above for the Sorting only. Don't use this for the values of the cells. For that use your initial values.

    By the way, seems like your original switch statement has some redundancy that could be eliminated. This would be different for any values not listed in your switch but other wise would give you the same results:

    =IIF(Fields!model.Value = " ", "NULL" , 1)