title: changing bar fill colours in ssrs chart
body: <p><a href="https://stackoverflow.com/questions/4993343/ssrs-field-expression-to-change-the-background-color-of-the-cell">SO Post</a></p>
  
  <p>Current I've got 5 bars in my RS chart - in the future there might be 7 bars or 17 bars or 27 bars!</p>
  
  <p>With a couple of bars I can have an expression like this:</p>
  
  <pre><code>=iif(Fields!Market.Value = "Spain"
  ,"Gold"
  ,iif (Fields!Market.Value = "Denmark"
      , "Gray"
      , iif(Fields!Market.Value = "Italy"
          , "Blue"
          , "Purple"
          )
      )
  )
  </code></pre>
  
  <p>If I can't predict how many countries will be included + I'd rather not have to hard code in "Green", "Red" etc how do I change the expression?</p>
  
  <p>I've tried this but it is erroring:</p>
  
  <pre><code>=Switch(Mod(Fields!Rank.Value/CDbl(2))=CDbl(0), "Gold", 
     Mod(Fields!Rank.Value/CDbl(3))=CDbl(0), "Gray", 
     Mod(Fields!Rank.Value/CDbl(2))&gt;CDbl(0) "Blue")
  </code></pre>
  
  <p>Above is the totally incorrect syntax: This works:</p>
  
  <pre><code>=Switch(CDbl(Fields!Rank.Value Mod 2)=CDbl(0), "Gold", 
     CDbl(Fields!Rank.Value Mod 3)=CDbl(0), "Gray", 
     CDbl(Fields!Rank.Value Mod 2)&gt;CDbl(0), "Blue")
  </code></pre>
  
  <p>Ok - the above runs (not sure how!) but the below is based on help from Dominic Goulet and is really easy to follow and nice and expandable to more colours; this is the solution for 5 colours:</p>
  
  <pre><code>=Switch(CDbl(Fields!Rank.Value Mod 5)=CDbl(0), "Gold", 
     CDbl(Fields!Rank.Value Mod 5)=CDbl(1), "Gray", 
     CDbl(Fields!Rank.Value Mod 5)=CDbl(2), "Green", 
     CDbl(Fields!Rank.Value Mod 5)=CDbl(3), "Red", 
     CDbl(Fields!Rank.Value Mod 5)=CDbl(4), "Pink")
  </code></pre>