title: SSRS Conditional Formatting
body: <p>I am working on SSRS Ranking report, where Rank 1 should have background of Green and last Rank should have background of Red. </p>
  
  <p>Example below:</p>
  
  <p><a href="https://i.stack.imgur.com/5Uycd.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/5Uycd.jpg" alt="SSRS Conditional Formatting"></a></p>
  
  <p>I tried using custom code but that's not working for me as below:</p>
  
  <p>SSRS Expression used as below:</p>
  
  <pre><code>=Code.RankColour(me.value, 1, Fields!RankName.Value)
  </code></pre>
  
  <p>And RankColor code as below:</p>
  
  <pre><code>Public Function RankColourTotals(ByVal Value As Decimal, ByVal MinValue As Decimal, ByVal MaxValue As Decimal) As String
      Dim strColor As String
  
      Select Case Value
          Case MaxValue
              strColor = "Salmon"
          Case MinValue
              strColor = "LightGreen"
          Case Else
              strColor = "Gainsboro"
      End Select
      Return strColor
  End Function
  </code></pre>
  
  <p><strong>Note</strong>: I am using SQL 2008 R2</p>