SSRS expression not working properly - reporting-services

I have one expression in my SSRS report which use to display currency data in the report. When there is no data NULL in the particular row it should display $0. However, it is displaying #Error.
=IIF(Fields!Value.Value="Nothing","$0",FormatCurrency(Fields!Value.Value,0))
I tried with IsNothing function as well but getting same result.

Take the quotes off Nothing..
=IIF(Fields!Value.Value=Nothing,"$0",FormatCurrency(Fields!Value.Value,0))

Related

Display Parameter in SSRS Report

When a user runs the report, they can select a multi-value parameter. I know I can use Parameters!Value.Label(0), Parameters!Value.Label(1), etc to display the each of the values based on their location within the array, but the number of the values changes based on how many values the user selects.
The report separates each value onto a separate page. I'm looking to (a) have an expression that identifies which value's info is displayed on the page, and (b) an expression that labels the tab as the value when the report is exported to Excel. I expect the same expression would work for both.
I believe I should be using Array.IndexOf(Split(Parameters!Value.Label.ToString(), ","), Parameters!Client.Label), but just get #Error as the output when the report renders. I'm not sure, but it seems like the Array... expression would only identify the location within the array.
Could someone offer some insight into where the syntax is wrong? I'm not sure if the issue is syntax or it's an issue of how to specify which dataset to use in the expression.
Thanks.
This is what you should use
=Join(Parameters!CSR.Label, ", ")

Hashed field not displaying in SSRS

I have a query that is using this convert function that correctly displays the data when I preview it in the SSRS Dataset:
CONVERT(varchar(255), HashedFileNum, 1) AS HashedFileNum
returns values like
0x7BB9D2F1A8A1B39832B95B932DD73A31
However when I try to add that field to my report I get #ERROR in the field instead of the value.
Any suggestions on getting the value to show in my report?
Try converting to nvarchar instead of varchar; I've had a similar issues in the past.

#Error in Column With both Text and Numeric Values in ssrs reports

In my report for one field i have both numeric and text values.( i.e 10.546 and "vary")
So when i apply CDec function for this field values i get #error where i have filed value as "Vary" .
10.6572 10.6572
Vary #Error
i tried expression "
=IIf(IsNumeric(Fields!price.Value),
CDec(Fields!price.Value),
"Fields!price.Value)"
but it is not working.
i checked in net in most of the cases all telling to write function, unfortunately in my project that is not allowed.
so is their any way i can resolve this "#Error" using expression.
I got solution.
=iif(IsNumeric(Fields!EUnit.Value), VAL(Fields!EUnit.Value),Fields!EUnit.Value)
this is working fine to me.
Ref : https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ac2c9db4-85a5-44a8-909b-1ee09791542e/ssrs-check-if-the-field-value-is-numeric-or-not?prof=required

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:

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.