Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Expression in sql change color

Author  Topic 

hbadministrator
Posting Yak Master

120 Posts

Posted - 2013-04-22 : 13:53:44
I have to Fields one is an estimate time =Sum(Fields!ettc.Value) ecct1 and the other field is =Sum(Fields!hours_bill.Value) Textbox21

I would like to then take the textboxes and say ecct1 - Textbox21 if greater than 2 then Text Color Red. How would I accomplish this?

hbadministrator
Posting Yak Master

120 Posts

Posted - 2013-04-22 : 14:56:17
I got my answer. =IIF((ReportItems("ettc1").Value - ReportItems("textbox21").Value)> "2","Orange", "White")
Go to Top of Page

hbadministrator
Posting Yak Master

120 Posts

Posted - 2013-04-22 : 17:24:05
ok I only got part of it lol. How do I get it to say =IIF((ReportItems("ettc1").Value - ReportItems("textbox21").Value)> "-2","Orange", "White") and =IIF((ReportItems("ettc1").Value - ReportItems("textbox21").Value)< "-2","Orange", "White")

So any thing that is over 2 it will show up red and if anything that is less than -2 is orange Anything within that 1.99 range is white.
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-04-22 : 17:44:57
You should be able to use nested IIF's - i.e., instead of putting "White", put the second IIF. Alternatively, you can use the SWITCH statement, something like this (I don't have BIDS to test, so if there are syntax errors, please overlook
=Switch(
ReportItems("ettc1").Value - ReportItems("textbox21").Value > -Red
ReportItems("ettc1").Value - ReportItems("textbox21").Value < -2,"Orange",
"White"
)
Go to Top of Page
   

- Advertisement -