Dealing with blank or null in ssrs - reporting-services

In my report, I have an expression which is used to pass a parameter to a child report parameter which is set to allow null values. The expression is :
=IIf(Parameters!Lead.Value = "False",Nothing,Fields!Paid.Value)
The above expression returns values only when Fields!Paid.Value is not blank. Therefore when Fields!Paid.Value is blank I get an error
"the value provided for the report parameter is not valid"
How do I modify my expression to parse these two conflicting issues?
What I want is to be able to return values when the Fields!Paid.Value is blank or when it is not. So at all time when the expression runs corresponding values are returned without the error stated above.
Thanks for helping out.

The first thing you do, wherever you have used the "Paid" parameter, set it to allow null value. Allow null only not blank.
The second thing about the expression, use something like this,
=IIF(Parameters!Lead.Value "FALSE", Nothing, IIF(IsNothing(Fields!Paid.Value),0,Fields!Paid.Value)

Related

Why my parameter shows me an error Failed to evaluate the FilterValues of the DataSet?

I want to get available values from query in my ssrs report parameter.
I set Get values from a query
DataSet : name of my dataset#
Value field: my field
Label field : my field
To get an idea i will show you what i mean:
For expected results : I want to use my parameter as multie value parameter..
Your expression should be something like this and you need to add this expression by pressing fx next to value rather than directly adding it.
=IIF(Parameters!RootPoint.Value(0)="",Fields!C_RootPoint.Value,Parameters!RootPoint.Value(0))
also if you are trying to check if your first parameter value is null then you should try like below
=IIF(Isnothing(Parameters!RootPoint.Value(0)),Fields!C_RootPoint.Value,Parameters!RootPoint.Value(0))

Check null and split value in textbox in SSRS report

I am facing very simple issue but not getting solution over it.
I have textbox in my ssrs report, I am passing value "1;prashant" or null to it. Now, if I pass value "1;prashant" to textbox then textbox should show only "prashant" and If I am passing nothing then it should be blank.
I have tried following IIF condition:
=IIF(IsNothing(FieldS!WIAPPORVER.Value),"",Split(Fields!WIAPPORVER.Value,"#")(1).ToString())
But, I above code is giving an error ["#error" shows in textbox] if I am passing blank value.
Please let me know, where I am wrong in this.
Thanks
There are probably better ways of doing this, but this is what my head came up with at the time:
=IIF(
IsNothing(Fields!WIAPPROVER.Value)
,""
,Right(Fields!WIAPPROVER.Value,Len(Fields!WIAPPROVER.Value) -InStr(Fields!WIAPPROVER.Value,";"))
)
I believe SSRS is trying to compute everything in the report at runtime, so in your case it is still trying to fetch index 1 from an array even though there is nothing in it and it crashes.
Edit: Changed parameters to Fields. I created a parameter to remake the issue at my side.
Just get the split out of the iif. Then in your iif, if field is nothing create a string that when split will return ""
=Split(IIF(IsNothing(FieldS!WIAPPORVER.Value),"#", Fields!WIAPPORVER.Value),"#")(1)
You are relying on the IIf expression short circuiting, but SSRS IIf expressions do not short circuit - the expression will try and work out Split(Fields!WIAPPORVER.Value,"#")(1).ToString() for all rows and fail when this value doesn't exist.
You can get this going by using text expressions, which don't get this error.
With test data:
And a simple table:
I have added columns with both your existing expression and a new expression:
=Right(Fields!WIAPPORVER.Value, Len(Fields!WIAPPORVER.Value) - InStr(Fields!WIAPPORVER.Value, "#"))
This new expression works for NULL values, empty strings and strings with no delimiter present:

Blank Parameter to Null Parameter in SSRS

I have a drilldown report whose parameters are: parent report - #valid Nvarchar(20) = '' and in child report - #valid Nvarchar(20) = Null.
Both reports run very well but I have an issue after mapping up this parameters in the Text Box Properties > Action > Go to Report. When the report is run I get the error,
"the value provided for the report parameter is not valid"
The query for this report is from a stored Procedure. In the child report, Parameter Properties, I have ticked the "allow Null values" text box, Set available parameter to come from a query and specify a default value to come from a query. What have I done wrong to allow for the error returned? Your help is appreciated.
Thank you.
If you're second report is expecting a NULL values, (i.e. Nothing in SSRS), you can pass an expression-based parameter to the child report based on the parent parameter, making sure that if it's an empty string at the parent level, you can explicitly set this to Nothing:
=IIf(Parameters!valid.Value = "", Nothing, Parameters!valid.Value)
This way the empty string will never get passed and your child report; only the NULL value it expects.
if you're considering passing a null parameter from URL, let's say some sort of CLI, you must include a parameter:isNull=True in the parameter section of the URL. and allways remenber to check the "allow null value" in report editor, parameter properties.
let's say we have a report, of sports and stadiums, and we have a null sport... it would be something like this>
http://<server/report>&rs:Command=Render&rc:Parameters=false&rc:toolbar=false&sport:isNull=True&stadium=CampNou
Set the Parameter to Allow Blank = Yes and the Default Value = "". In the code make allowances for the blank parameter.

Adding Fields into an expression in an SSRS 2008 report

Thank you in advance for taking your time to answer my question.
I am having trouble with expressions in the SSRS reporting system.
The Field I am adding required fields from the dataset I provided in the report, however when I try to preview the report I get the Following message:
"A Value expression used for the report parameter ‘Policies_Total’
refers to a field. Fields cannot be used in report parameter
expressions."
This is my expression:
=IIF(Sum(Fields!policy_id.Value, "DataSet1") Is Null, 0, Count(Sum(Fields!policy_id.Value, "DataSet1")))
That was suppoed to be converted from Crystal reports which has the following expression:
If IsNull ({usp_rep_agent_cases;1.policy_id}) then
0
Else
Count ({usp_rep_agent_cases;1.policy_id})
Any help is much appreciated.
Thank you
I think it may be as simple as understand that a 'parameter' should be passed into SSRS before fields are created for the most part. If this parameter is DEPENDENT on the value of something else first being chosen you cannot list it first as the field is not yet populated to my knowledge. It appears you are trying to use an expression to count something from a field from a dataset when you just make a dataset and reference that field directly. So instead of trying an expression you may choose a few other options instead:
Choose on the left pane of your parameter 'Available Values' selected 'Get values from a query'. You may use your query which is a 'dataset', value is self explanatory, label is what the end user will see display.
The option 'Allow null' value will accept a null value
You may run into situations where multiple datasets may need to be used, multiple selects or querying objects. In my experience with SSRS it gets mad at times when you try to reference a dataset used to display data with a dataset used to determine an event or action. SSRS also gets relativity slower the more Expressions you do so doing a whole report with nothing but expressions versus taking the power of the built ins of the RDL language is not really worth it IMHO.
For SSRS expressions you need to use IsNothing for NULL checking, something like:
=IIF(
IsNothing(Sum(Fields!policy_id.Value, "DataSet1"))
, 0
, Count(Sum(Fields!policy_id.Value, "DataSet1"))
)
In fact the whole expression seems a bit odd; what are you specifically trying to achieve with your expression? Are you just trying to count non-null values?
=Sum(IIf(IsNothing(Fields!policy_id.Value), 1, 0), "DataSet1")
Also, your error seems to be saying that a parameter is referencing a field when this isn't allowed, which may not be solved by changing syntax; I think more information about what you're trying to achieve is required here.

Parameter is missing a value ssrs 2008

I have a parameter of integer datatype which is hidden. When i run the report, report gives me an error
Parameter X is missing a value
However if i make the parameter visible it works. I tried providing default value of 0 but that does not suffice my requirement as i have sub-report(Drill-dowm) depended on this parameter. Please help. Thanks!
Make sure that you have not specified Available Values for the parameter. Available Values should be "None" for internal and hidden parameters.
First of all,
Check that parameter's - Available Values by going to report parameters properties.
It must not be specified any values. So we should set it as None
Second work around is,
Just add a blank space at Specify values - in Default values inside report parameters properties.
This will surely work. Hope it will save your time.
I had to do an "if exists" statement for this to go away. It worked for me because it makes it always return a value even if that value is not need by my query.
if exists (my select query)
my select query
else
select '2'
// '2' would never be used, but it made ssrs stop giving me
// the stupid error and execute the rest of the query
If you specify available values from query, then default values must be in list of available values. Default value in (Available) = true.
The problem occurs also, if you have a parameter that depends of another one without "default value" inside the Dataset Query and does not admit null value.
For example:
Parameter 1 have a default value: NameEmployee from the dataset "EmployeeSearch"
But the dataset "EmployeeSearch" have a filter or a parameter inside the query named #Month that indicate the number of the month. So if the value of #Month is null, SSRS will say "Parameter is missing a value".
Assuming you had the same issue as I had, trying to run the report on a web page using a ReportViewer component, I managed to fix that issue by adding a null parameter before rendering the report:
C# code:
var parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("ParameterName", (string)null));
ReportViewer1.ServerReport.SetParameters(parameters);
Hope that will help
Just need to add 1 default value to get around this error (even though that default value will never be used).
-Under "Report Parameter Properties" for that specific parameter, go to the Default Values page.
-Toggle "Specify values"
-Add a value (I added: "just_a_filler_to_get_around_hidden_value_error" so when I look back at it later I remember why I did such a thing)
-click OK
I want to add to dmbreth's CORRECT answer.
I was missing the concept that the value of the parameter still needed to be tied to something. Originally, I was tying the output of a dataset by using the Available values portion of the parameter properties, but according to dmbreth's answer, that could not be the case. Finally I moved my output dependence settings from the Available Values section to the Default Values section and that did the trick.
So, in summary, in the parameter properties dialogue:
General Page - Allow multiple values checked(this option is specific to my application), parameter visibility set to internal
Available Values Page - None
Default Values Page - Get values from query, [appropriate dataset, value here]
Advanced Page - No significance here
Hopefully, that is clear enough to benefit someone else with the same problem...
I had a similar issue where the default value as set by SSRS is (Null), I didn't need the parameter for my report however; I found it useful for testing to filter down the list so I kept it, I guess I could have deleted it in SSRS on the dataset config. but I changed it to =System.DBNull.Value (I guess this could be any expression) instead and that worked for me, so then I can still pass in a value if need be and also set Available values (had to make sure a NULL value was added to my dataset) if I then decide to unhide at a later date.
There is one other potential here. I have had a situation where the report designer works but the server report object does not. The solution is to delete the server object and then re-save it from the designer.