I have a text box within an rdl report which I want to suppress based on certain terms in my dataset (i.e. if the query returns a term which ends with the letter "L" then hide the text box).
Within the textbox properties I have set visibility expression for Hidden with the below expression:
=First(Fields!STERMS__.Value, "Job") NOT LIKE '%L'
When I run it I get the error:
"The Visibility.Hidden expression for the text box contains an error:
[BC30201] Expression expected"
It seems like a schoolboy error but I have tried various permutations on this expression with no luck. Any help would be appreciated.
SSRS expressions are funny in some ways. I think what you're looking for is:
=IIf(First(Fields!STERMS__.Value, "Job") Like "*L", True, False)
The gist is that SSRS doesn't use SQL syntax. It's VB
I think you could use the Right() function which returns a specified number of characters from the right hand side of a string.
E.g.
=Right(Fields!STERMS__.Value,1)
I guess in your case for Hidden property on the cell, the expression would look like this
=IIF(Right(First(Fields!STERMS__.Value, "Job"),1)=="L",true,false)
Related
I have a multi row dataset that I want to do a lookup on and take the bit/Boolean value of one of it's columns and apply it to the hidden property of a tablix.
Here is the expression for the hidden property on the tablix.
= IIF(Lookup(6, Fields!ServiceOfferingID.Value, Fields!UseCustomCalculator.Value, "JobBuyerDetails") = 0, True, False)
If the ServiceOfferingID is 6, get what is in the UseCustomCalculator column to show or hide the tablix.
I don't know if you can compare values like this, what may need to be a string or if they are all just variants.
I have tried converting the values to string with CStr(), putting quotes around the searched value (6 in this case) but have had no luck getting the tablix to show or hide correctly.
There doesn't seem to be a good way to debug this, check what the Lookup is returning etc.
How can I change my expression to get it to work?
What am I missing?
I am pretty new to SQL Server Reporting Services.
I am using SQL Server 2008 R2.
Debugging in the traditional sense isn't really an option. What I normally do is add a textbox and set the expression to the expression you want to test, in your case, set the expression to
=Lookup(6, Fields!ServiceOfferingID.Value, Fields!UseCustomCalculator.Value, "JobBuyerDetails")
and see what you get.
Once you've established what is being returned and corrected the comparison then you can simplify the hidden expression a little.
The hidden expression would just be something like (assuming lookup issues are resolved)
=Lookup(6, Fields!ServiceOfferingID.Value, Fields!UseCustomCalculator.Value, "JobBuyerDetails") = 0
There's no need to use an IIF here as the comparison will return return or false anyway.
In SQL server reporting services(SSRS) tablix cell, i want to write an expression as follows:-
set the value of variable and use that variable in "if" condition.
i have written following expression and its working fine, only issue is i want only "if" condition to be evaluate.
currently output is : "TrueVariable text is NA"
=Variables!myVar.SetValue("NA")
&IIf(Variables!myVar.Value="NA","Variable text is NA","Variable text is not NA")
The result you get is because you are concatenating both expressions, the assignment and the conditional.
The assignment returns "True" and the conditional "Variable text is NA" therefore the result is "TrueVariable text is NA"
if you want just the result of the conditional you can for example wrap the assignment inside an IIF, and as it always will be true, then you can do something like this
=IIF(Variables!myVar.SetValue("NA"),
(IIf(Variables!myVar.Value="NA","Variable text is NA","Variable text is not NA"), "should never get here"
)
This SO link, WHERE Caluse in SSRS expression, verifies that my syntax is correct yet I get this error:
"An error occurred during local report processing.
The definition of the report is invalid.
The Value expression for the text box 'txt1A_EMA' uses an aggregate expression without a scope. A scope is required for all aggregates used outside of a data region unless the report contains exactly one dataset."
My expression:
=Sum(IIF((Fields!COU_EMA.Value, "CA_Summary") = 1, (Fields!Amount.Value, "CA_Summary"), 0))
There are 3 Datasets in my report. The one I want is "CA_Summary" and the expression above was built with the expression builder.
The field, (Fields!COU_EMA.Value, "CA_Summary"), is a boolean (1 or 0) and I get error either with a 1 or a "true" (no quotes).
I probably could fix it if I knew what the definition of "scope" is. . . maybe.
The scope is where you want to look in order to get the values you're looking for. It could be a data set, group, etc. In your expression it appears CA_Summary is the scope.
I would try modifying the expression a bit. Since you say COU_EMA is bit field, maybe use TRUE. This is also assuming the matrix is using the data set CA_Summary.
=Sum(IIF(Fields!COU_EMA.Value = TRUE, Fields!Amount.Value, 0))
If your matrix isn't using that data set and it still doesn't work try
=Sum(IIF(Fields!COU_EMA.Value = TRUE, Fields!Amount.Value, 0),"CA_Summary")
To meet my expectation, I have tried this code in fontweight expression as well as field value expression
=iif(fields!RATE_SELECTED="A","BOLD","NORMAL")
I end up with an exception
Error BC30518: Overload resolution failed because no accessible '=' can be called with these arguments
Please help.
You are missing .Value in expression.
It should be:
=iif(Fields!RATE_SELECTED.Value="A","Bold","Normal")
Also, it should be "Bold","Normal" instead of "BOLD","NORMAL"
and due to some SSRS bug, if you try this, and it still doesn't work,then the trick is:
Try first clearing the previous values and then Click OK >> OK till you again reach the Report Designer screen.
From here, again right click your report item, say TextBox, right click >>TextBox properties >>Font>> fx (near Bold) and when you here
then, instead of manually writing the full expression, write only =iif( then click on Fields [see fig] and choose RATE_SELECTED ,similarly click on Constants and double click Bold, and then Normal
then, with your manual edit, the final expression should be like
=iif(Fields!RATE_SELECTED.Value="A","Bold","Normal")
HTH
I am using the following expression in one of my report fields.
=Fields!Value.Value*(Fields!DutyRate.Value/100)
This works as exprected as long as there is a valid value in the Fields!DutyRate.Value.
My problem is that the Fields!DutyRate.Value can contain non numerical values such as "Free".
This means any rows with the word "Free" in them causes an #Error. This is OK as such but I would like to get SSRS to display something other than #Error. In fact I would like to to display "F" instead.
Many thanks
You can use an IIF (inline if statement) and the IsNumeric function.
Syntax: IIF(<condition>,<true part>,<false part>)
=IIF(IsNumeric(Fields!DutyRate.Value),Fields!Value.Value*(Fields!DutyRate.Value/100),"F")
SSRS Expression Examples
Visual Basic Functions (SSRS expressions use VB functions)