sqlsql-servervisual-studio-2010reporting-servicessql-server-2012-datatools

Sorting Column in SSRS by Background Color


Is it possible to sort a column in SSRS by background color? For example, if I have an expression that will make the cell either RED or GREEN, is there a way to have all the columns with RED background cell colour sorted before listing cells which have GREEN as the background cell?

Thanks.


Solution

  • No, I don't think you can do this. The only thing I could think of is referring to ReportItems in the sort expression, but that causes scoping issues (you would get a build error in VStudio), because the sorting is done on the tablix and the background of cells is done one level lower.

    However, most likely, your background color expression is either static (does not refer to data), or depends on data. You can use the exact same expression for sorting too. So say you have this for background:

    =Iif(Fields!Nr.Value > 10, "#FF0000", "#00FF00")
    

    You could equally well sort the tablix by:

    =Iif(Fields!Nr.Value > 10, 1, 0)
    

    Or of course sort in SQL already:

    ORDER BY Nr