I have a report connected to BI cube. In the report there is a parameter with the datasat from the cube as well. This parameter correctly appears as a multi-select drown down in the report viewer, and the values are correctly populated.
However, when I am calling the report using javascript and passing the report parameters as a post request, there is an interesting behaviour.
If in the parameter, I pass a value that is not included in the list, the report crashes with the following error:
Default value or value provided for the report parameter 'Name' is not a valid value. (rsInvalidReportParameter)
Is there a way to make SSRS simply skip the invalid values rather than throw an error?
Without knowing more on what is 'acceptable' for the parameter value this question is nearly impossible to answer. In SSRS the first level of acceptance of a parameter is the type which is the common 'text' (string of equivalent in code), integer or DateTime. If you are passing a parameter to the report NOT in the format it wants it will bomb. That should be as designed.
If you limit your scope of 'available' values of a parameter by attaching the parameter to a dataset stating: "Get values from Dataset". If you give the parameter a value NOT in this collection it will also bomb. This would be the argument equivalent of selecting 6 when your choices are 1-5. And getting the standard .NET equivalent of 'argument is outside the bounds of the array.' That is also by design.
For debugging I would suggest trying to set the value in SSRS as the 'default' statically and if it can accept it then the issue is in the transfer and the type. If you can and then cannot from the web pass in via javascript or whatever method you choose it is the type being passed in. In such cases I have passed in a string and then transferred it's type in SSRS dynamically with a cast.
Related
I'm working in report builder, calling a stored procedure that has a parameter that, when null, sets itself to a certain value. I want to display what this parameter is set to on the report. From experimenting, Report Builder's parameter collection only shows the parameter as it is sent from the report.
Alternatives that I've considered but can't get to work or are sub-optimal:
Adding the parameter to the select statement. The main drawback is this won't display a value if there are no results.
Using a return value or output parameter. There doesn't seem to be a way to do this.
Re-creating the "null" logic in the stored procedure. The correct output is displayed but this is a code fork.
How can I display this value? Is there a way to show a return value or output value?
You could change the procedure to return the parameter value in a UNION ALL select so that a row with the parameter value will always be returned. That row could have NULL for all the other columns so that you can filter it out in the rest of the report.
Another possibility is to add a second dataset to the report that does nothing but get the value of the parameter based on what you pass. That, however, is also a sort of code fork. The fork could be mitigated, however, by putting it in a UDF, and resourcing the same UDF in both datasets.
Yet another possibility is to replicate the logic of populating the parameter in a Custom Code block in the report. However, that is also a code fork.
I've never worked in Report Builder interface but I do have quite a bit of experience building reports in BIDS/VS... There it's a simple matter of setting the parameter default, in the rdl, to match the default in the stored procedure.
I'm attempting to create a filter on a tablix in Report Builder 3.0. I click on the Tablix, choose Properties and then click on Filters. Clicked on Add and created my filter:
Expression [SYSTEM_CODE]
Operator =
Value 1005
I don't get an error message but when I run the report, nothing is showing when I know there's valid data for that system code. It doesn't matter what value I choose, I don't see anything when I run the report. It also doesn't matter if I enclose the value in single or double quotes. There is no grouping on this report so there's no filter there either.
I'm pulling my hair out because this should fairly simple.
I had a similar issue and maybe what I found will work for you. I created a simple query to show you what I found (note the Convert statement is intentional here):
Select getdate() as "MyDate", CONVERT(Decimal(12,0), 1005) As "System_Code"
I then created a filter for the System_Code value. Note the Float value in the Type field that you cannot change.
Screen shot of disabled Type field
When I ran the report, I got this error:
The processing of FilterExpression for the tablix ‘Tablix1’ cannot be
performed. Cannot compare data of types System.Decimal and
System.Double. Please check the data type returned by the
FilterExpression.
I know, it says Decimal to Double (I blame Microsoft as this baffled me too). This is happening because this type of parameter can only process Integer and Float values. Report Builder doesn't let you change them as it infers this type from the dataset (based on my own experience). If you set the query to return an Integer, the filter will work:
Select getdate() as "MyDate", CONVERT(Integer, 1005) As "System_Code"
However, checking the Type field will still be disabled, and may show as float. Selecting another value in the drop down expression field then selecting back to the System Code value will change the Type value from Float to Integer.
The funny thing is, if you try another Convert data type value, i.e. BigInt, you will get that you cannot convert from Int64 to Float (/sigh Microsoft).
The closest I could get to seeing why this is happening, after many hours of searching, was this page on Microsoft's site which discusses that the value expected is an Integer or a Float. Even though I am not performing a Sum function, the effect appears the same.
Sum Function (Report Builder)
I got the Tumbleweed badge for this question.... :)
I've moved on a little from the original question but still looking at using internal/hidden parameters, this time passing to another report which runs a stored procedure (which sends an email).
The main report (report A) has a parameter called StudentCourses (originally called ReportParameter1) which I have tried both as Hidden or Internal, and currently has ticked Allow blank value and Allow multiple values.
(Its default value is a field from the result of a query, which shows the courses a student is enrolled on).
Action for my textbox no longer goes to URL (to open PHP form) but now uses Go to report to call report B. Under action options I've added two parameters; StudNetworkID and StudCourses. The number of courses can vary from 2 to 5.
The new report (report B) has two parameters also called StudNetworkID and StudCourses; both are Hidden and StudCourses has ticked Allow blank value. [All parameters are text, btw].
If Report A StudCourses is set to =Parameters!StudentCourses.Value(0) then the first course is shown on Report B. So far so good.
If Report B StudCourses is set to Allow multiple values, then Report B shows #Error and the Warning description given is "[rsInvalidExpressionDataType] The Value expression used in textrun ‘Textbox3.Paragraphs[0].TextRuns[0]’ returned a data type that is not valid."
If Report B StudCourses is set to NOT Allow multiple values and Report A StudCourses value is set to [#StudentCourses] then Report B shows the text "[#StudentCourses]".
If Report B StudCourses is set to Allow multiple values again, then I get the same invalid data type error as before.
Having turned off Allow multiple values on Report B to avoid the #Error issue...
Setting Report A StudCourses to =Parameters!StudentCourses.Value(0) & Parameters!StudentCourses.Value(1) then Report B shows course 1 and course 2 on one line. OK so far.
However, setting Report A StudCourses to =Parameters!StudentCourses.Value(0) & Parameters!StudentCourses.Value(1) & Parameters!StudentCourses.Value(2) gives me a runtime error that the Index was outside the bounds of the array (because there are currently only two courses). On clicking the textbox, Report B just says "The 'StudCourses' parameter is missing a value".
OK...
I turned off Allow multiple values on Report A StudentCourses parameter (the one holding the result from the query) and for the Go to report parameter StudCourses I added the other values, so eventually had value(0) to value(4), the result was interesting. For each parameter value used it gave me a letter from the first course on Report B. Hence when I included up to value(4) it gave me the first five letters of course one!
Yep, ok, this is because it is no longer reading multiple values and so specifying a number just returns the letter from that position.
SO...
How do I allow for up to 5 courses to be passed over???
What follows below is the original question
I have a small report designed in Visual Studio that displays courses that a student is enrolled on. The number of courses can vary from 2 to 5, depending on the student.
Also on the report is a text box, which when clicked will action a url to open a PHP form.
I have worked out how to pass the user id to this PHP form but, if possible, I would also like to pass the course titles.
If I use internal report parameters* I can add these to the url, like this:
="http://myurl/webform.php?param=" & Mid(User!UserID,InStrRev(User!UserID,"\")+1)
& Parameters!ReportParameter1.Value(0)
& Parameters!ReportParameter1.Value(1)
& Parameters!ReportParameter1.Value(2)
& Parameters!ReportParameter1.Value(3)
& Parameters!ReportParameter1.Value(4)
but unfortunately I get the runtime error "The Hyperlink expression for the text box 'Textbox7' contains an error: Index was outside the bounds of the array."
If I just put the first two report parameters it works fine.
I tried using parameter count, e.g. iif(Parameters!ReportParameter1.Count > 2, Parameters!ReportParameter1.Value(2), " "), but I still get the same error.
Please can someone show me how to get around this runtime error, or suggest another way to do this?
Thanks
PS * Report Parameters set up as Text, Allow blank value, Allow multiple values, Internal, Available Values = None, Default Values = Get values from a query; Value field = course title.
I have an SSRS 2012 Report that is based on a MetricsData dataset that contains the field "REPOSITORY". The report also has a second dataset, PlanITData, containing the fields:
RepositoryName
AppName
AppOwnerName
I put an expression into one of the report columns containing the following Lookup:
=Lookup(Fields!REPOSITORY.Value,Fields!RepositoryName.Value,Fields!AppName.Value,"PlanITData")
I expected it would look up the REPOSITORY from MetricsData (the dataset that should be in the scope of the report and does, in fact, display in one of the report columns), find the matching RepositoryName from PlanITData and return the AppName from PlanITData. I get all blanks in this column. I've run the underlying query for the PlanITData dataset with known values and it returns the appropriate values. Do I not understand the Lookup function? This is my first time trying to use it...
Edit: I just saw this warning. I'd swear it wasn't there earlier. No idea what this means:
Warning 1 [rsLookupOfInvalidExpressionDataType] The Value expression
for the textrun ‘LOBGROUP.Paragraphs[0].TextRuns[0]’ uses a lookup
function with an expression that returned a data type that is not
valid for the lookup function. The data type must be an RDL Variant
type.
Apparently the expression above is correct. I kept playing with the datasets and suddenly it started working. Apparently there was an issue with how the datasets were constructed but I'm not sure what it was...
I have a report with integer parameters and while passing the parameters from WPF client to ReportParameter object, it gives an error:
"The best overloaded method match for 'Microsoft.Reporting.WinForms.ReportParameter.ReportParameter(string, string[])' has some invalid arguments".
How can I pass an integer type parameter to my SSRS report from my WPF client?
you should not use toString() to pass values to a integer parameter.
The ideal for parameters being passed from outside the report is set them as "Text". You dont even have to cast them (to integer in your case) on the dataset. For example, if you have a ID parameter like this:
where ID=#ID
you can create it as text and pass it as a parameter from the URL like if it were a text