I have a multi-parameter report in SSRS where I want to display or hide a report depending on the parameter selection. If the user selects only one facility from a multi-value facility parameter then I want a second report to display along with the main report(it would be a separate tab). If multiple facilities are chosen then I only want the main report to display.
I've been playing with the visibility expressions on the second report but I can't seem to get it to work.
I've tried:
=IFF(Parameters!entity.IsMultiValue, "True", "False")
but that returns an error "The hidden expression used in tablix returned a data type that is not valid.
I've also tried:
=IIF(Parameters!entity.Count = 1), "False", "True")
But I get the same error. I'm using SSRS 2016.
False and True are not strings but constants.
Change it to:
=IIF(Parameters!entity.IsMultiValue="Your value", True, False)
And the second one to:
=IIF(Parameters!entity.Count = 1, False, True)
Good luck.
True and False are not strings, they are booleans. The Visibility property looks for a boolean, but in the expressions you gave (assuming your syntax was correct when testing it), you are passing strings since you have them enclosed in double quotes. Remove the double quotes and that will clear that error.
You also don't need to use IIf here -- you can simply use the first argument of the IIf, since that by itself will evaluate to True or False. I doubt there is any appreciable performance difference, but just a small thing to note.
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.
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")
I have a rectangle.
I want to hide it if a field (X) is NOT NULL.
I tried this but it is not working:
=IIF(NOT IsNothing(Fields!filepath.Value), 1, 0)
I get the error:
An error occurred during local report processing.
The Hidden expression used in rectangle 'ID2398' returned a data type that is not valid.
Anyone know why I'm having this issue?
Do I need to place the actual field onto the report? I tried it but I keep getting the same error.
If you're using that for the Visibility expression, I believe you need to explicitly use True/False rather than 1 or 0. So try:
=IIF(NOT IsNothing(Fields!filepath.Value), True, False)
I do prefer to use =iff(Fields!filepath.Value IsNot Nothing, Fields!filepath.Value, ) in Textbox/Properties/Visibility/Hide as it is more intuitive for me.
In SSRS 2005, I'm trying to set up an expression to return true or false, according to whether the value of one of the ReportItems is in a list of (possibly multiple) values selected by the user from a list when the report is run.
Here's the expression so far:
=iif(Trim(ReportItems!Category_2.Value) = Trim(Parameters!Category.Value(0)), False, True)
You can see that True and False in the expression are reversed - this is because it's to control the 'Hidden' property of the row, and I want to NOT hide rows where the value is in the list.
The expression works fine when choosing single values for the parameter, but for multiple values, it only displays the results for the very first.
Hope you can help.
Try using
=iif(Trim(ReportItems!Category_2.Value) = Trim(Parameters!Category.Value), False, True)
Many thanks for your help. These multiple values were really bugging me, and I never managed to get Trim to work properly, so I ended up using the following two-stage solution, instead:
(1) In the SQL 'SELECT' statement, I defined a new value called 'InCategory', assigning it a value of 1 or 0 according to whether the Category was one of the inputted Categories or not:
CASE WHEN Category IN (#Category) THEN 1 ELSE 0 END AS 'InCategory',
(2) Then in SSRS, my expression for the 'Hidden' in the report became simple, hiding the row if the sum of 'InCategory' for that row was 0:
=iif((Sum(Fields!InCategory.Value) = 0), True, False)
Thank you again for your help - I much appreciate it, and will use this site again.
I am working on a SSRS Report.
In the report , i need do display a field of type: boolean that is either true or false.
When I try to display it on the report , it's showing as true/false.
But, I would like to represent it as yes if value is true and no if false.
I think one way of doing is by changing the query that gets data to report.
But I would like to know, is there any way we can write that condition in the report itself
to change representation.
You can use an expression field, add a textbox, right click => expression and use something like this: =IIF(Fields!LineTotal.Value = True, "This is true", "This is False")