Sunday 6 October 2013

SSRS - Order By Day Of The Week

In SQL Reporting Services there is no out of the box way of order a report or chart by the days of the week. If you try to order by the name you end up with the days alphabetically sorted which is not very helpful.



One of the ways around this is to click use a switch statement in the Sort By section.

=SWITCH(Fields!DateNamePart.Value = "Monday", 1, Fields!DateNamePart.Value = "Tuesday", 2, Fields!DateNamePart.Value = "Wednesday", 3, Fields!DateNamePart.Value = "Thursday", 4, Fields!DateNamePart.Value = "Friday", 5, Fields!DateNamePart.Value = "Saturday", 6, Fields!DateNamePart.Value = "Sunday", 7)

After you have added this the days are now sorted in order and the data now has some visual value and it is much easier to spot when the trend in the chart.