Thursday, November 20, 2008

When IIF() statements just won’t do.

Maybe I’m not the first one to figure this out, but I didn’t find anything when I was googling for an answer yesterday.

So I was trying to do some conditional formatting in Microsoft Reporting Services…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.

The instructions that I found said to use an expression like this in the background color property for the cell:

=IIF(Fields!Whatever.value=”Yes”,”Green”,”Red”) (If the “Whatever” field contains the value “yes” then make the background green, or else make it red.)

That didn’t work for my three color option, since IIF statements can only do two colors…one color if it’s true, one color if it’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.

What I did was I added a case statement to my SQL query for each color.  It looked like this:

SELECT
CASE Some_Field WHEN ‘Yes’ THEN ‘Green’
WHEN ‘Maybe’ THEN ‘Yellow’
WHEN ‘No’ THEN ‘Red’
ELSE ‘White’
END AS ‘Color’
FROM Some_Table

I then set my background color for the cell in the report to:

=Fields!Color.value

It worked perfect.  I hope someone finds this useful.

Posted in Programming, SQL | No Comments »

A comment about the Bible

I frequently visit Reddit.com to read news, comment on the news, and attempt to debate with other people.  I wrote this comment ealier in response to another commenter in an article about Barack Obama and some statements he made about having a nation based on the Bible.  I thought the comment I made would make an interesting read for anyone who sees this.  This isn’t the entirety of what I believe about the Bible, but it is a good summary.

Apparently you are missing point of the article, and really don’t understand the bible at all.

If you read the article, then you realize that Obama’s points make sense. The Bible contradicts itself several times, and is nonsensical throughout many passages.

That wasn’t his point at all. He was pointing out that while many Christians say that we need to follow the Bible, a lot of them don’t even know what parts they want followed. And it’s not a matter of contradiction….it’s a matter of how things changed from Old Testament to New Testament. The New Testament, very basically, says that the stuff in the Old Testament is no longer needed to absolve sin, because Christ did it once for all men with his death.

Calling such things contradictions is like reading the beginning of a book where someone is alive, then reading the end where the person is dead, and calling it a contradiction because the book said the person was both alive and dead. You have to read the stuff in between to understand what happened to make that change.

Honestly, though many parts of the Bible are beautifully written and expound beautiful truths, there are other parts that are just awful.

Here’s the trap that a lot of people, Christian and non-Christian alike, fall into. They see the Bible as an instruction book, when it’s really not. I blame the Christians for this, because they’ve been touting it as an instruction book for a long time.

The truth of the matter is that the Bible is a history book. It is a collection of writings from various ancient authors who recorded what happened. Just because something is in the Bible does not mean that it is good. Many evil things are recorded as having happened…as history is filled with evil things along with good.

Nowhere in the Bible is the reader commanded to do anything. The Old Testament is mostly history of the Hebrew people, prophecy, and some philosophy. In the New Testament, the gospel books record what Jesus said and did. The book of Acts records what the early Church was like. The books after that are the Epistles (mostly letters from the Apostles to various churches).  A lot of people read these Epistles as though they were written to them, and not to a church that existed 1700+ years ago.  Not everything is meant for us today, and it is left to the reader of the Bible to figure out what all of it means and what to do with the knowledge.

Posted in Religion | 1 Comment »