While working with a stacked bar chart in SQL Server Reporting Services (SSRS), I needed to change the sort order for the legend without changing the sort order of the stacked bar. Despite the fact I personally think stacked bar charts are a poor way to visualize data people still want to use them. Didn’t they read my post on charting best practices?!? One of the tricks with a stacked bar chart is that only the bottom value can actually be measured. Thus, we frequently want to force the most important measure to sort to the bottom of the stacked bar. Uh oh! Once you sort the most important measure to the bottom of the stacked bar, the legend will now be sorted with the most important measure on the far right, most likely where the least important value would be described. I was starting to think it wasn’t going to be possible to correct this annoyance until I stumbled on a clue in a thread on another site (On SSRS 2008, Why Is The Legend Sorted In Reverse Order?) Most of the suggestions didn’t actually change the sort order of the legend without changing the sort order on the chart (again, stacked bar for my example). Buried among the suggestions which didn’t work were a few sentences, apparently from Sean Boon of the SSRS Team (Boon Blog), which did the trick.
Instead of right clicking on the legend and looking at the “Legend Properties” as I was want to do. The trick to sorting the legend was in the *other* legend properties window.
1. Click the legend to select it.
2. Then press “F4” to open the properties window. (alternatively you can select “Properties Window” from the View menu.)
3. Within the properties window find the intuitively named attribute “Reversed”. There are only three options in SQL Server Reporting Services 2008: “Auto”, “True”, and “False”. Experiment with the True and False settings to achieve the desired effect.
That’s it. You are now an SSRS stacked bar legend sorting wizard. Prepare to bring in the big bucks!