<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JimVernon.com &#187; Programming</title>
	<atom:link href="http://jimvernon.com/archives/category/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://jimvernon.com</link>
	<description></description>
	<lastBuildDate>Tue, 01 May 2012 08:41:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>When IIF() statements just won&#8217;t do.</title>
		<link>http://jimvernon.com/archives/67</link>
		<comments>http://jimvernon.com/archives/67#comments</comments>
		<pubDate>Wed, 25 Jun 2008 18:22:27 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://jimvernon.com/?p=67</guid>
		<description><![CDATA[Maybe I&#8217;m not the first one to figure this out, but I didn&#8217;t find anything when I was googling for an answer yesterday. So I was trying to do some conditional formatting in Microsoft Reporting Services&#8230;in particular, I was trying to change the background color of a cell depending on what the value in that [...]]]></description>
			<content:encoded><![CDATA[<p> 	Maybe I&#8217;m not the first one to figure this out, but I didn&#8217;t find anything when I was googling for an answer yesterday.</p>
<p>So I was trying to do some conditional formatting in Microsoft Reporting Services&#8230;in particular, I was trying to change the background color of a cell depending on what the value in that cell was.  I could only find instructions on how to change the color for two possibilities.  I had three possibilities, and needed three colors.</p>
<p>The instructions that I found said to use an expression like this in the background color property for the cell:</p>
<p><strong>=IIF(Fields!Whatever.value=&#8221;Yes&#8221;,&#8221;Green&#8221;,&#8221;Red&#8221;)</strong> (If the &#8220;Whatever&#8221; field contains the value &#8220;yes&#8221; then make the background green, or else make it red.)</p>
<p>That didn&#8217;t work for my three color option, since IIF statements can only do two colors&#8230;one color if it&#8217;s true, one color if it&#8217;s false.  Actually, now that I think about it, I probably could have used another IIF statement for the false value, but oh well, I like this solution more.</p>
<p>What I did was I added a case statement to my SQL query for each color.  It looked like this:</p>
<p><strong>SELECT<br />
</strong><strong> </strong><strong>CASE Some_Field WHEN &#8216;Yes&#8217; THEN &#8216;Green&#8217;<br />
</strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong>WHEN &#8216;Maybe&#8217; THEN &#8216;Yellow&#8217;<br />
</strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong>WHEN &#8216;No&#8217; THEN &#8216;Red&#8217;<br />
</strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong>ELSE &#8216;White&#8217;<br />
</strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong>END AS &#8216;Color&#8217;<br />
FROM Some_Table</strong></p>
<p>I then set my background color for the cell in the report to:</p>
<p><strong>=Fields!Color.value</strong></p>
<p>It worked perfect.  I hope someone finds this useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://jimvernon.com/archives/67/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

