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 2005 Forums
 Transact-SQL (2005)
 Conditonal Formatting

Author  Topic 

sergeant_time
Yak Posting Veteran

73 Posts

Posted - 2010-07-01 : 12:39:21
Hello,

I have a conditonal format in my report layout that changes the text color when the Value > 10. The expression works, but not correctly. My goal was to change the text color to red (>10) or green (<10). It does not change the color correctly. It either remains red or green regardless if the value is less than or greather than 10.


=Iif(((FIELDS!Q1_Excellent.Value) + (FIELDS!Q1_DontKnow.Value) + (FIELDS!Q1_Poor.Value) +(FIELDS!Q1_Fair.Value)+ (FIELDS!Q1_Neutral.Value)+ (FIELDS!Q1_VeryGood.Value))<>0,IIF((((Fields!Q1_Poor.Value + Fields!Q1_Fair.Value))/((FIELDS!Q1_Excellent.Value) + (FIELDS!Q1_DontKnow.Value) + (FIELDS!Q1_Poor.Value) +(FIELDS!Q1_Fair.Value)+ (FIELDS!Q1_Neutral.Value)+ (FIELDS!Q1_VeryGood.Value)))< 10.0,"Red","Green"),"Black")


X002548
Not Just a Number

15586 Posts

Posted - 2010-07-01 : 12:49:44
Is this Access, Excel, or reporting Services?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

sergeant_time
Yak Posting Veteran

73 Posts

Posted - 2010-07-01 : 12:56:01
This reporting services (SSRS 2005)

quote:
Originally posted by X002548

Is this Access, Excel, or reporting Services?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam





Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-07-01 : 13:02:20
Shouldn't it be this way

....(FIELDS!Q1_VeryGood.Value)))> 10.0,"Red","Green"),"Black")




Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

sergeant_time
Yak Posting Veteran

73 Posts

Posted - 2010-07-01 : 13:08:10
:(, I tried this prior to posting. When I select my parameters and get my results it just do the oppossite. Regardless if its greater than or less than 10, changes the text to green.

quote:
Originally posted by Idera

Should it not be this way

=Iif(((FIELDS!Q1_Excellent.Value) + (FIELDS!Q1_DontKnow.Value) + (FIELDS!Q1_Poor.Value) +(FIELDS!Q1_Fair.Value)+ (FIELDS!Q1_Neutral.Value)+ (FIELDS!Q1_VeryGood.Value))<>0,IIF((((Fields!Q1_Poor.Value + Fields!Q1_Fair.Value))/((FIELDS!Q1_Excellent.Value) + (FIELDS!Q1_DontKnow.Value) + (FIELDS!Q1_Poor.Value) +(FIELDS!Q1_Fair.Value)+ (FIELDS!Q1_Neutral.Value)+ (FIELDS!Q1_VeryGood.Value)))> 10.0,"Red","Green"),"Black")




Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH

Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2010-07-01 : 13:19:26
I woult no embed this long code just for conditional formatting. can you not do this in your stored proc that is called by the report. there you do the ifs as CASE statements. then you can specify colors there, even color code.

SELECT CASE WHEN X <> 0 THEN 'Red' (or #FF0000)
CASE WHEN x > 10.0 THEN 'Green' (or #408080)
ELSE 'Black'

FROM x

what if tomorrow you want to add aqua color, are you gonna come into the report and mess with this long code again. IMHO best to break this out to the called sproc.

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -