ssrs show text different colour when field matches with another field - reporting-services

I have a requirement to show different text color when one field matches with another three different fields.
I have written below expression,
=IIF(Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value or Fields!DegreeBlockLetter.Value or Fields!AwardBlockLetter.Value, "Green", "No Color")
But its not working.
I am using SSRS report builder.

That's not how the OR works.
You would need to use something like..
=IIF(Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value or Fields!OrderBlockLetter.Value = Fields!DegreeBlockLetter.Value or Fields!OrderBlockLetter.Value = Fields!AwardBlockLetter.Value, "Green", "No Color")

Related

Change text box color in SSRS based on value

I am creating a SSRS report and I have column named Priority and I want to change background color of that particular box based on the value.
This is what I have tried
=SWITCH(Fields!Priority.Value = Critical, "Red", Fields!Priority.Value = High, "Green", Fields!Priority.Value = Average, "Yellow", Fields!Priority.Value = Low, "Blue")
Error:
The BackgroundColor expression for the text box ‘Priority1’ contains an error: [BC30451] Name 'Critical' is not declared.
Thank you
The values on the right side of your equal signs need to be in double quotes.
=SWITCH(Fields!Priority.Value = "Critical", "Red", Fields!Priority.Value = "High", "Green", Fields!Priority.Value = "Average", "Yellow", Fields!Priority.Value = "Low", "Blue")
EDIT: Just to add a little description in case it's not clear: you need those double quotes since you're comparing to those strings. Bare words in expressions are assumed to be keywords, so when it gets to the word Critical and can't find any keyword associated with that, it doesn't know what to do. If you were comparing numbers, you would not need the quotes, but since you are dealing with strings in this case, you do.

Changing color of body report, depending on value in table

I have report in SQL Server 2008.
Report has a parameter, parameter values:
organization1
organization2
organization3
organization4
To display a list of parameter with values, I used "Available Values" "Get values from a query".
If value of organization1 parameter in "Value" column is greater than
20, then report body and background of tables should be in red color.
If selected parameter organization1 background of tables and report body should be in red color.
If selected parameter organization2 background of tables and report body should not be in red color.
If selected parameter organization3 background of tables and report body should be in red color.
If selected parameter organization4 background of tables and report body should not be in red color.
The expression below does not work for selected parameter.
=IIF(Fields!AVID.Value, "summ_work">20 and
First(Parameters!ReportParameter1.Value, "test")="Organization1","Red","Transparent")
How can I fix it?
You're going to need something like this for the BackGround expression in the report.
=Switch(Sum(Fields!value.Value, "DataSet1") > 20 And Parameters!Organization.Value = "Organization1", "Red",
Parameters!Organization.Value = "Organization1", "Red",
Parameters!Organization.Value = "Organization2", "White",
Parameters!Organization.Value = "Organization3", "Red",
Parameters!Organization.Value = "Organization4", "White",
True, "Yellow")
That last line of the Switch is a catch all that will turn the background Yellow. Do what you want with that, or remove it entirely if you don't think the situation will happen where someone passes a parameter value other than what you have in the list.
I went with White as the "should not be in red" color, change that to something else if you like.

ssrs show text different colour when field matches with another

I have a requirement to show different text color when one field matches with another three different fields.
I have written below expression,
=IIF(
Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value, "Green",
or Fields!OrderBlockLetter.Value = Fields!DegreeBlockLetter.Value, "Orange",
or Fields!OrderBlockLetter.Value = Fields!AwardBlockLetter.Value, "Blue", "No Color")
But its not working. When saving this code it gives error.
I am using SSRS report builder.
You can't use IIF with OR like that. IIF just returns a value if the expression is true and another if it's false. You can nest IIFs to get the desired results but using SWITCH is much simpler. Try this... (not tested but should be close enough)
=SWITCH
(
Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value, "Green",
Fields!OrderBlockLetter.Value = Fields!DegreeBlockLetter.Value, "Orange",
Fields!OrderBlockLetter.Value = Fields!AwardBlockLetter.Value, "Blue",
True, "Black"
)
As switch returns on the first true expression, if all the others fail, the final expression is always True so the "Black" will be returned.
EDIT: Actually, "No Color" is not a valid font. You either need to pick black (the default color), or white (to give the appreance of there not being text there)

SSRS multiple right IIF / SWITCH query

I want to change values to display in a report based on the right 3 characters of the column name..
=SWITCH (Right(Fields!Column_Name.Value,3) = "Pred", "Green",
(Right(Fields!Column_Name.Value,3) = "Lvl", "Blue")

SSRS customized pie chart color

I have a doubt here,
I need to show a pie-chart in SSRS, for the student results according to their status(Pass/Fail).......I have only 4 conditions Male-pass,Male-fail,Female-pass,Female-fail,I need to show these things with my own color,
for this am using the switch condition as
=Switch(
((Fields!Gender.Value = "Male")&(Fields!Status.Value="Pass")), "Blue",
((Fields!Gender.Value = "Male")&(Fields!Status.Value="Fail")), "HotPink",
((Fields!Gender.Value = "Female")&(Fields!Status.Value="Fail")), "Orange",
((Fields!Gender.Value = "Female")&(Fields!Status.Value="Pass")),"LimeGreen" )
but in the preview it shows only the default color set, not the customized one, can anyone fix this one...thanks in advance
Try using something like
=IIf((Fields!Gender.Value = "Male") and (Fields!Status.Value="Pass"),"Green",
IIf((Fields!Gender.Value = "Male") and(Fields!Status.Value="Fail"),"Red" ,
IIf((Fields!Gender.Value = "Female") and (Fields!Status.Value="Fail") ,"Blue",
(Fields!Gender.Value = "Female") and (Fields!Status.Value="Pass"),"Yellow","Orange"
,"#00000000"))))
You should be able to get it working using the Switch statement as well. The problem with your expression is that the logical "and" operator in SSRS is And, not ampersand. In SSRS, a single ampersand is used for concatenating strings. So your expression is concatenating the string representation of the two boolean results, resulting in strings like TrueFalse. This should actually giving an error on the Switch evaluation.
A correct Switch statement would be this:
=Switch(
Fields!Gender.Value = "Male" And Fields!Status.Value="Pass", "Blue",
Fields!Gender.Value = "Male" And Fields!Status.Value="Fail", "HotPink",
Fields!Gender.Value = "Female" And Fields!Status.Value="Fail", "Orange",
Fields!Gender.Value = "Female" And Fields!Status.Value="Pass","LimeGreen"
, True, "SomeOtherColor"
)
I've also added an "else" part to the switch in case some records are not covered by the other conditions. If you're 100% sure that won't happen, you can remove the line that starts with "True". But it shouldn't hurt to keep it either.
More info: Pie Chart Techniques (look for Custom Coloring chapter)