all groups > sql server reporting services > september 2005 >
You're in the

sql server reporting services

group:

Setting cell colour based on values


Setting cell colour based on values Peter Nolan
9/17/2005 8:01:08 AM
sql server reporting services: Hi All,
I think there must be a better way....and someone here must know it...
;-)

I am building reports to do revenue variance from plan analysis.

I have the forumula below working to produce the amount and protect
from the divide by zero error. However, I also want to set the colour
of the background of the cell for both the amount and the percentage
variance....

Initially, I'd like to set it for -5% or worse= red, -5% - +5% = amber
and +5% and above green....

And thinking about it...it would actually be really good to have the
percentage as a parameter on thre reports that defaults to 5% to change
the colours....

But it looks like I must repeat this forumla in each case...or must I?

Has anyone else done this kind of colour coding for revenuye variance?

Thanks

Peter
www.peternolan.com

PS. This is the forumla I mentioned...

=IIf(sum ( Fields!resp_tot_plan_amount.Value )= 0 , 0 , (sum(
Fields!resp_tot_act_amount.Value ) - sum (
Fields!resp_tot_plan_amount.Value ))/ IIf(sum (
Fields!resp_tot_plan_amount.Value )= 0 , 1 , (sum (
Fields!resp_tot_plan_amount.Value ))) )
Re: Setting cell colour based on values Wayne Snyder
9/18/2005 7:52:52 AM
If you are repeating this over and over, you may wish to create a small
function in the CODE section which accepts the variance, and returns a
string with the name of the color.

Then in the expression box for the color, make the call to the function ie
=Code.myColorsetter(Fields!myvariance.Value)

--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)

I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org

[quoted text, click to view]

Re: Setting cell colour based on values GeoSynch
9/18/2005 4:46:35 PM
Hi Peter,

Supposing you've set up two parameters named paramRed
and paramGreen that will accept Integer value between
1 and an upper limit of 99 and the textbox name for the
percentage calculation is txtRevenuePct, then this (hopefully)
should do the trick:

In txtRevenuePct's Background Color property, type this expression:
Iif ( [Your formula below] <= Parameters!paramRed.Value / 100, "Red",
Iif ( [Your formula below] >= Parameters!paramRed.Value / 100, "Green",
"Amber" ) )

Slight modification to your formula:
=Iif ( Sum ( Fields!resp_tot_plan_amount.Value ) <> 0 ,
( Sum ( Fields!resp_tot_act_amount.Value ) -
Sum ( Fields!resp_tot_plan_amount.Value ) ) /
Sum ( Fields!resp_tot_plan_amount.Value ) , 0 )


GeoSynch


[quoted text, click to view]

AddThis Social Bookmark Button