Search code examples
sortingvisual-studio-2013report-designer

Visual Studio report sort zero as high


I have a numerical field that I want to use to sort my report (in descending order). However, I want to show any zero values first.

Is there a way to sort zero first and then high to low?


Solution

  • Applying the idea I found here when researching a different issue, I was able to get this working.

    Create an expression for the first sorting column, using a switch statement to sort zeros first:

    = Switch( Fields!NumericAmount.Value = 0 , 0,
              1 = 1,                         , 1)
    

    Then you add a second sorting column, picking your "NumericAmount" field in descending order.
    This gives me my desired sorting order (0, 68, 64, 48, 3, 2, 1)!