SSRS Expression for color error - reporting-services

I've got this expression for my percent column to work out which colour to use based on several column values in my SSRS report.
=IIF(Fields!GrossMarginActual.Value = 0 AND Fields!GrossMarginPercentageActual.Value = 0, 0, Fields!VarianceGrossMargin.Value) AND
IIF(Round(Fields!VarianceGrossMargin.Value,2) < 0.00, "Red", "Black")
However I get the following
The color expression for the text run 'VarianceGrossMarginPercent.Paragraphs[0].TextRuns[0]' contains an error: [BC30205] End of Statement Expected.
I am guessing my syntax on my expression isn't quite right. I've wrapped extra brackets round it but that just gives me back errors. This correct syntax doesn't flag up any errors in the expression box.
Would appreciate a second pair of eyes to look over it.

Try this:
=IIF((Fields!GrossMarginActual.Value = 0 AND Fields!GrossMarginPercentageActual.Value = 0, "Red",
IIF(Round(Fields!VarianceGrossMargin.Value,2) < 0.00, "Red", "Black")))

Related

SSRS Conditional Formatting with 3 Colours

Trying to figure out conditional formatting for SSRS/Visual Studio and trying to get the figures to show this as an expression as follows;
Below benchmark needs to be Red
Above but within 5% needs to be Gold
More than 5% above needs to be Green
Benchmark 60%
Year 1 62.2%
Year 2 67.4%
Year 3 43.6%
First time in writing something like this so unsure what the best step is!
=iif("Textbox83" > "Textbox82", "SpringGreen", iif("Textbox83" < "Textbox82", "Red", iif("Textbox83" = "Textbox82" + 0.05,"Gold", "Transparent")))
A few things here..
Use SWITCH rather than nested IIFs, it much easier to read and debug.
You would normally work against the dataset fields rather than the textboxes displayed on the rendered report. If you do refence the textboxes, you probably have to convert the values to numeric before comparison
If you reference an object, either a dataset field or an rendered textbox, you must state the property you want, typical .Value
If this was being done against dataset fields you would do something like this
=SWITCH (
Fields!myValue.Value < Fields!Benchmark.Value, "Red",
Fields!myValue.Value <= (Fields!Benchmark.Value * 1.05), "Gold",
Fields!myValue.Value > (Fields!Benchmark.Value * 1.05), "Green",
True, Nothing
)
Switch stops at the first expression that results in True so the sequence of conditions is important. The final expression pair True, Nothing acts like an ELSE and returns nothing (which is the default backgroundcolor property, which appears as transparent)
If you wanted to replicate this using the textboxes (don't unless you really have to!) then it's basically the same but a bit more messy.
=SWITCH (
VAL(ReportItems!TextBox83.Value) < VAL(ReportItems!TextBox82.Value), "Red",
VAL(ReportItems!TextBox83.Value) <= (VAL(ReportItems!TextBox82.Value) * 1.05), "Gold",
VAL(ReportItems!TextBox83.Value) > (VAL(ReportItems!TextBox82.Value) * 1.05), "Green",
True, Nothing
)
The above is from memory and therefore untested but it should be OK.

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 Pie chart hide 0 Value

SQL Server 2012 - SSRS Questions
I currently have a Pie chart that shows the number of deliveries as a percentage on whether they are late, on time or early. What I am trying to do is use an Expression in the Chart Series Labels "Visible" property to hide the label if it is 0 on the chat. Of note in the table this value is returned as 0.00 I have tried using various SWITCH and IFF Statements to do this but nothing seems to work and its likely I am getting the syntax wrong, can anyone help?
Table Values
TotalIssued Early Late OnTime EarlyPerc LatePerc OnTimePerc
6, 0, 4, 2, 0.00, 66.67, 33.33,
=SWITCH(
(First(Fields!EarlyPerc.Value, "EstimatesIssued") = 0),false,
(First(Fields!LatePerc.Value, "EstimatesIssued") = 0),false,
(First(Fields!OnTimePerc.Value, "EstimatesIssued") = 0),false,
true)
Thanks
Try:
=SWITCH(
First(Fields!EarlyPerc.Value, "EstimatesIssued") = 0,false,
First(Fields!LatePerc.Value, "EstimatesIssued") = 0,false,
First(Fields!OnTimePerc.Value, "EstimatesIssued") = 0,false,
true,true)
UPDATE:
If you have one field per percentage and your dataset returns one row always, you have to select each serie in the ChartData window and press F4 to see properties window.
In properties window set for EarlyPerc Visible property:
=IIF(Fields!EarlyPerc.Value=0,False,True)
And so on for the next two series you have (LatePerc and OnTimePerc).
Let me know if this helps.

How to Sum Visible Rows Only SSRS

I am trying to sum only the visible rows only in SSRS and I have read a few forums that say you need to put:
=Sum( iif( <The condition of Visibility.Hidden expression>, 0, Fields!A.Value))
However I am unsure on how this works, my visibility code is:
=iif(Fields!Sub.Value = "Ins", True, IIF(Fields!Sub.Value = "Ins - Int", True, False))
When I add this into the above 1st code i get #ERROR.
Appreciate any help.
Thanks
Try this:
=Sum(iif(
Fields!Sub.Value = "Ins",
0,
IIF(Fields!Sub.Value = "Ins - Int", 0, Fields!A.Value)
))
Note I am not using the same expression for hiding the rows, I am just using its logic.
Hopefully this is what you are looking for, let me know if you need further help.

Sum the expression

I need to sum this expression
= IIf(Fields!SupplyStrategyTypeName.Value="Supply",0,
IIf(Fields!IP_DA_FIN.Value>225,Fields!IP_DA_FIN.Value-225,0))
I tried following the example of the previous question but I get an error.
Any help on this?
You didn't list what you tried or the error you got so here's what should work:
=SUM(IIf(Fields!SupplyStrategyTypeName.Value = "Supply", 0,
IIf(Fields!IP_DA_FIN.Value > 225, Fields!IP_DA_FIN.Value - 225, 0)) )
So if a row of data's SupplyStrategyTypeName is Supply or IP_DA_FIN is 225 or less, it would result in 0 otherwise it would be IP_DA_FIN - 225. Then the sum will sum all the results.
Don't be worried about using too many spaces - they make it more readable when you go back through your formulas to figure out what's wrong.