title: DAX: how to assign color hex code based on text value?
body: <p>I am trying to change the color of a text column based on the text itself:</p>
  <ul>
  <li>VERY GOOD: green</li>
  <li>GOOD: light green</li>
  <li>FAIR: yellow</li>
  <li>BAD: orange</li>
  <li>VERY BAD: red</li>
  </ul>
  <p>I wrote the following DAX expression:</p>
  <pre><code>RAG = 
       VAR Category = SELECTEDVALUE('Data'[Text]) 
       RETURN SWITCH(Category = &quot;VERY GOOD&quot;, &quot;#41AC4C&quot;, 
                     Category = &quot;GOOD&quot;, &quot;#AFC236&quot;, 
                     Category = &quot;FAIR&quot;, &quot;#FFD400&quot;, 
                     Category = &quot;BAD&quot;, &quot;#E95A1A&quot;, 
                     Category = &quot;VERY BAD&quot;, &quot;#E42925&quot;) 
  </code></pre>
  <p>However, applying this function in Power BI returns the error message:</p>
  <p><strong>Error Message:</strong>
  MdxScript(Model) (6, 148) Calculation error in measure 'Data'[RAG]:</p>
  <p><strong>Function 'SWITCH' does not support comparing values of type True/False with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.</strong></p>
  <p>What am I doing wrong?</p>
  <hr />
  <p>These are my version details:</p>
  <pre><code>Feedback Type:
  Frown (Error)
  
  Release:
  September 2020
  
  Product Version:
  2.85.681.0 (20.09) (x64)
  
  OS Version:
  Microsoft Windows NT 10.0.18363.0 (x64 en-GB)
  
  CLR Version:
  4.7 or later [Release Number = 528040]
  </code></pre>