SSRS Math with Conditional Images - reporting-services

I have an SSRS report generating KPIs. Each KPI is measured from 0%-100%, where the goals for Red (bad)/Yellow/Green (best) vary between KPIs. Some may give green for 40%, and some others may require 95%.
The images that display next to the KPI are already coded to be conditional on the value of the KPI itself. For one example:
=Iif(
ReportItems!LaborEntry.Value >= 0.95,
"Green",
Iif(
ReportItems!LaborEntry.Value >= 0.85,
"Yellow",
"Red"
)
)
Where "Green," "Yellow," and "Red" are the images in the report which correspond to the values.
NOW, here's the question: how would I count up how many greens are in my report, for example? I need to be able to score them, but I don't necessarily know at run-time what each image will be.

Nested calculations can get messy. When you encounter a situation like this, it usually makes sense to create a calculated field on your dataset. In this case, make your IIf statement a calculated field. This simplifies the expression to select an image. And of course it is trivial to simply aggregate your new column!

Related

How do you sum a field and set the background color depending on the result in ssrs?

In an SSRS report, I have a single row that is totals. Some fields are negative and some are positive. Some are zero. I wish to be able to set the background color depending on the value. Red for <0, Green for >0 and no color for 0.
Also, I would like to show the absolute value, so no minus signs. The color will determine if <0 or >0.
It looks like it might be something like this:
=IIF(Sum(Fields!OffenseCount.Value = 0), "No Color", IIF(Sum(Fields!OffenseCount.Value = 0) > 0, "Green", "Red"))
but I can't get it to work this way and this doesn't even address the Abs issue
If you could also point me to a good reference for formulating these expressions, that would also be useful.
Thanks!
Well, I didn't get that the IIF statement had to be in the fill color. I thought it was in the expression for the cell. Got that sorted out and everything else became easy. Hopefully, my ignorance and solution will help someone else.

SSRS 2013 - Changing colour of cell dependent of outcome of expression within cell

I've asked a similar question recently (See below) however I'm now struggling with a similar scenario.
I have a cell with an expression which is a formula to calculate a % difference, and then depending on the value the percentage difference, I want the cell to change colour. if it's over 1% red, if it's under 1%, green.
The current expression which works to calculate the percentage is;
=(Sum(Fields!P1RateAmount.Value) - Sum(Fields!P1Amount.Value)) / (SUM(Fields!P1Amount.Value)) * 100
I'm presuming I need to wrap a IIF around it, but when I have tried it hasn't worked
If anyone could help me with this I'd be very grateful
Also for context, the formula can't be done in SQL to get a number as I'm using collapsing columns and the percentage formula I'm using in SQL brings back the first row when used within SSRS, and doesn't take into account the full sum
Previous Question asked as referred to above
The expression for the BackgroundColor property of your text box would be:
=IIF( (Sum(Fields!P1RateAmount.Value) - Sum(Fields!P1Amount.Value)) / SUM(Fields!P1Amount.Value) * 100 > 1, "#fff5fa", "MintCream")
I prefer a light shade of green or red but you can substitute the colors with Red and Green if you want to hit them over the head with it.
Just for anyone who may be looking at something similar, the following worked for me
=Switch(
me.value <=-1 OR me.value >=1, "Red"
,me.value >-1 OR me.value <1, "Green"
)
I think this is because the cell already had an expression of
=(Sum(Fields!P1RateAmount.Value) - Sum(Fields!P1Amount.Value)) / (SUM(Fields!P1Amount.Value)) * 100
to get number, the 'IIF' and then referencing the cells wouldn't work. However me.value would look at the value of the cell rather than working the formula, thus bringing back the desired colour

Rotate fill color by group in SSRS

I need to have each record to rotate background fill in SSRS but each record is grouped into two rows, I have tried the solution that others have used but they are not working.
This is the expression I have tried:
=IIf(RowNumber(Nothing) Mod 2 = 0, "Silver", "Transparent")
It seems odd because it looks like its working but about the 6th group down it will put two groups together with the same color. so this needs some sort of adjustment.

ssrs 2008 R2 rounding Fill expression value to match displayed percentage

I have a textbox which I need to colour format based on an expression.
Here is the value in the textbox:
=iif(Fields!TotalStartsForTurnaround.Value=0
,Fields!Within2Hours.Value/Fields!TotalStartsForTurnaround.Value)
The textbox is formatted to show the value as percentage with 0 decimal places.
I have the following fill colour criteria:
If value <90% then red
If value >=90% and <96% then Orange
if value >=96% then Green
The Fill expression is as follows:
=iif(Fields!TotalStartsForTurnaround.Value=0,"White"
,iif((Fields!Within2Hours.Value/Fields!TotalStartsForTurnaround.Value)<0.9
,"Red"
,iif((Fields!Within2Hours.Value/Fields!TotalStartsForTurnaround.Value)>=0.9
and (Fields!Within2Hours.Value/Fields!TotalStartsForTurnaround.Value)<0.96
,"Orange"
,"Green")))
However say I have a value of 0.89999. The colour of the textbox is correct but because the percentage is being rounded.. the display value is 90%.
How can I get the fill expression to match up with the rounding of the percentage so that colour coding matches the percentage displayed?
Simplifying your expression for clarity, instead of using something like:
=IIf(Fields!MyValue.Value < 0.9, "Green", "Red")
In your BackgroundColor expression, Round the value being checked in the same way it is rounded in the the formatting:
=IIf(Round(Fields!MyValue.Value, 1) < 0.9, "Green", "Red")
This should mean what the user is seeing and what is being used in the colour check should match up.
A couple of things that might help:
Add a calculated field to your Dataset to represent the result of Fields!Within2Hours.Value/Fields!TotalStartsForTurnaround.Value - this will be usable in subsequent report expressions and help make the code easier to follow.
Use a Switch expression to determine the colour instead of a series of nested IIf statements.

SSRS 2008R2 Change Column Colour Based on Percentage Parameter Value

SSRS MSSQL 2008 R2
Hi
I have two parameters, "TopPerformersPercent" = 15 and "WorstPerformersPercent" = 20.
I want to be able to change the cells on one column (Total) based on these values.
The colour change needs to be based on a percentage value.
The "TopPerformersPercent" cells on the "Total" column should be in Green, i.e the Top 15 percent.
The "WorstPerformersPercent" cells on the "Total" column should be in Red, i.e the Worst 20 percent in Red.
And all the cells in between should be in Amber.
Is this possible, if so how?
Thank you in advance.
Assuming you have already calculated their "performer %" and have that available as a field in your dataset, use an expression like this for your background color for those cells:
=Switch(
Fields!Total.Value <= Parameters!WorstPerformersPercent.Value, "#00ff00",
Fields!Total.Value >= Parameters!TopPerformersPercent.Value, "#ff0000",
true, "#ffe4B5"
)
Fortunately your logic is simple, so we don't need to worry about multiple-positives scenarios here. The third line in the switch statement functions as a default, applying your amber color if neither of the first 2 conditions are met.