My report looks like in picture below: each row is a location, columns are dates, qty is a SUM.
In this example QTY would be 30, I would like to color it following logic:
If all parameters are the same and equal to some value apply color.
If all parameters are not the same apply color.
EDIT:
param is a part of Dataset
You should be able to use an appropriately scoped CountDistinct here in the Color or BackgroundColor expression as required. Something like:
=IIf(CountDistinct(Fields!param.Value, "MyGroup") > 1, "Red", "Green")
Where MyGroup is the Scope you want to look at; you might want to change it to the Scope of your DataSet or whatever. I've just assumed group based on your data.
In this expression, the highlight will be Red when there is more than one distinct param in Scope, otherwise Green.
Edit after comment
Where you want to group certain param items together, you could use a Calculated Field to group these together in your DataSet definition, then just use this as required in your report. The Calculated Field, let's call it paramColour, might look like:
=Switch(Fields!param.Value = "AA" or Fields!param.Value = "BB", "Orange"
, Fields!param.Value = "CC", "Green"
, true, "Red")
I used a Switch here to make it easier to add future values.
You can then use this directly to set properties, i.e. set BackgroundColor to this value, or just amend the expression above:
=IIf(CountDistinct(Fields!paramColour.Value, "MyGroup") > 1, "Red", "Green")
It's nice having a Calculated Field as you can define it once for the DataSet and use it in multiple places in the report.
Related
I trying to colour code a group within a group based on a value.
enter image description here
I am quite new to SSRS, and have tried various expressions, SWITCH, IIF etc but I cant seem to get them to reference the various criteria and groups correctly.
You've not explained what your criteria is so this is just a guess. I'm also assuming that the Target values are numeric, so 5 and not 5 days for example.
I'm also assuming that you want the background to be green is the count of DAYS2 >= Target
If this is the case then you can do something simple like this
=IIF(COUNT(Fields!DAYS2.Value) < Fields!Target.Value, "Green", "Red")
I have a matrix in my SSRS 2016 reporting services report. I am trying to set a conditional expression on background color for the sum(field.value). This field is formatted as a percent. Here is my expression which does not appear to have any errors:
Background Color Expression:
=Switch(Fields!PicturesbeforeFirstSignoutCount.Value<.80,"Red",Fields!PicturesbeforeFirstSignoutCount.Value >= .80 and Fields!PicturesbeforeFirstSignoutCount.Value < .95,"Yellow",Fields!PicturesbeforeFirstSignoutCount.Value >= .95,"lightGreen")
Problem: It turns everything "lightgreen" even when their textbox should be yellow's and red's in the matrix. there is one field that is highlighted as Red, but it should have been Yellow.
I tried to set this in the field property for background color expression. That just made everything "light green".
I changed it to the fill expression in the matrix Text box. Now I get mostly everything green except the one red field that should be yellow. I checked my numeric values and they are coming across in decimals points when I change the format back to number
Any help would be appreciated.
As Harry mentioned in the comments, you need to be evaluating the same expression as you are displaying.
Also you can simplify the SWITCH statement as follows.
=SWITCH(
SUM(Fields!PicturesbeforeFirstSignoutCount.Value) <.80, "Red",
SUM(Fields!PicturesbeforeFirstSignoutCount.Value) < 0.95, "Yellow",
True ,"LightGreen"
)
As SWITCH returns the first result where the expression is true, there is no need to put a range in. so if the value was 0.91 then the first expression would be skipped but the second one would be true to it would return "Yellow".
The final True acts as an "else".
How do change part of the string's color in SSRS based on conditional logic.
This is what the expression currently looks like:
=" Total Amount Due: " & FormatCurrency(ReportItems!GrandTotal.Value)
What I want to do is something like this iif(ReportItems!GrandTotal.Value >= 0, "red", "black")
but we only want to change the color of the GrandTotal field rather then the complete string.
I understand how to change color based on conditional logic, but I can't figure out how to change color based on conditional logic only for part of the expression
You can try to put the static text outside of your placeholder expression, but in the same textbox. You can then remove the "Total Amount Due" from your expression and you can set your conditional logic to the entire expression, which will only have the value.
I have a report that has 3 parameters: RaceDate, RaceCourse, SilksColours. The SilksColours parameter is optional.
If the SilksColours parameter is selected I want to highlight the row in my report with the colour yellow, while all the other rows stay white.
Is this possible?
For each TextBox in the row you want to highlight, you need need to set the Background Color property to be expression-based and compare the parameter value to value in the row, something like:
=IIf(Fields!Colour.Value = Parameters!SilksColours.Value, "Yellow", "White")
Edit after comments:
OK, as you've noted there are two questions here.
Parameter with default
You have a requirement to have a multi-value parameter with the ability to specify no value in particular. You can't set up a multi-value to accept NULL values, so you need to add a catch all value to the DataSet. So base the parameter on values similar to the following:
Set a parameter up to use this DataSet and set the Default Value to None:
Now we have a parameter with a default, which will not highlight any rows, so users can just ignore if they want or choose values as required.
There is one minor annoyance here - the user can select None and other values as well, they aren't mutually exclusive, but it should be good enough.
Highlighting rows
Next step is to set the Background Color values for all required TextBoxes. Since multiple colours can be selected, we need to treat multi-value parameters differently from single ones, something like:
=IIf(InStr(Join(Parameters!Colour.Value, ","), Fields!Colour.Value) > 0
, "Yellow"
, "White")
So what we need to do is use the JOIN function to create a string list of selected values, then check if the row value is anywhere in that list. Put it all together to get the following:
The report will load straight away as the parameter has a default value, with no rows highlighted:
Choose one colour and the row is highlighted:
Choose multiple colours to highlight multiple rows:
Hopefully all this is what you're after!
I have a chart which measures volume (y-axis) against date (x-axis). I have an Event table, which stores meaningful events, which I'd like to display as a vertical stripline on the chart. When there's data there, the field E_Text will be populated.
I've tried various methods, and am currently trying to only display using a change to the background colour, as such ("#00ffffff" is no colour):
=iif(Fields!E_Text.Value="","#00ffffff","Orange")
However, this statement always returns true, despite the data always being there. Has anyone managed to get data-driven striplines working?
Are you certain you are capturing nulls? A blank is something. NULL and (blank) are two different things. In SSRS Null is captured with Isnothing(), putting a value inside the parentheses. I have never had tried data driven strip lines with this method but this in the past has been an issue. Also can you test your function with an easier test first? EG: Set a simple dataset up and set the background color up with a dataset we know to have a null and a positive value:
Create test dataset
declare #Person Table ( person varchar(8), orders int);
insert into #Person values ('Brett', 10),('Sean', null)
select * from #Person
Put a table from the toolbox in and populate it with the two columns.
Set the background property of the [orders] column cell to
=iif( isnothing(Fields!orders.value), "White", "Red")
I now see a white and a red, HOWEVER if I do this:
=iif( Fields!orders.value = "", "White", "Red")
I get always white.