Extra "" after field transformation? - business-objects

Cant figure out why there is an extra "" in the query transform as below in the KEY:
The other fields are without "" and coming fine. Example as below:
I am stuck, please help.

Related

SSRS Expression - #Error in an obviously correct expression

I have an SSRS expression with this in it:
=IIF(
Fields!CUT.Value.ToString().Length > 1
,IIF(
Fields!CUT.Value.ToString().Contains(","),
Fields!CUT.Value.ToString().Substring(0, Fields!CUT.Value.ToString().IndexOf(",")),
Fields!CUT.Value.ToString()
)
,""
)
Translation:
If the field contains a ,, Get me the substring of the field from the first position to where the , is. If the field does not contain ,, just get me the entire field.
Probelm:
I get a #Error in all the pages where there is NO COMMA. If there is a COMMA, it works as expected. One of the fields, the value is 4. In a different scenario, the value is 17/64" Corrugated. I get an error for both of those.
What I've tried:
I've tried a few different approaches:
Used LIKE instead of Contains
=IIF(
IsNothing(Fields!CUT.Value)
,""
,IIF(
Fields!CUT.Value LIKE "*,*",
Mid(Fields!CUT.Value, InStr(Fields!CUT.Value, ",") + 1, (LEN(Fields!CUT.Value) - InStr(Fields!CUT.Value, ",") - 1))
Fields!CUT.Value
)
)
I added a new field to my dataset that replaces , with XXXX. I thought, maybe SSRS is not able to understand that I am talking about a , as a part of the string. And then changed the query to see if there is an XXXX in it. Still got the same #Error
Delete the .data file, cleaned the project, and rebuilt the project. Because, this is so obviously not incorrect. So I thought maybe it is not looking at the latest version of the report.
Nothing seems to do it! I am really close to doing something bad! This thing is driving me insane.
Questions:
Anyone see anything wrong with either of my expressions?
Is there a better way to do to what I am trying to accomplish? If there is a ,, give me everything before the ,. If not, give me everything.
Edit 1:
Worth noting that, in a different field, I am doing something very similar to this:
IIF(
IsNothing(Fields!CUT.Value)
,""
,IIF(
Fields!CUT.Value LIKE "*,*"
," | Length: " & Mid(Fields!CUT.Value, InStr(Fields!CUT.Value, ",") + 1, (LEN(Fields!CUT.Value) - InStr(Fields!CUT.Value, ",") - 1))
,""
)
)
What this is doing is, if there is a , in that very same field, get me everything AFTER the , and append it to | Length:. If there is no ,, just show an empty space "". This works perfectly fine. In situations where there is a , and where there is NO ,. So I've concluded that Microsoft is using SSRS to make me go crazy.
You could do this using SWITCH and test for no comma first but there is a much easier way assuming you only ever want to get the first part of the string up to the point of the comma.
This just uses the split function and takes the first element.
=(Split(Fields!CUT.Value, ",")).GetValue(0)
Nice and simple :)

SSRS SWITCH Syntax not working

I have a columns in my dataset that will be returning several different values. In an attempt to to use grouping in the report I am trying to clean up the data. After reading several posts I found this post that seemed to be very close to what I needed.
I set up my expressions like this
=SWITCH(
Left(Fields!T6_TOW_BY.Value,3)="ACE","ACE WRECKER",
Left(Fields!T6_TOW_BY.Value,3)="CAR","CAR STORE",
Left(Fields!T6_TOW_BY.Value,7)="THE CAR","CAR STORE",
Fields!T6_TOW_BY.Value
)
The expression does not throw an error when I preview it, but all the columns show "error" Can anyone please show me where I am going wrong here?
Thanks
The Switch statement requires pairs of arguments. You can't just have the last value by itself as an Else condition. Try this:
=SWITCH(
Left(Fields!T6_TOW_BY.Value,3)="ACE","ACE WRECKER",
Left(Fields!T6_TOW_BY.Value,3)="CAR","CAR STORE",
Left(Fields!T6_TOW_BY.Value,7)="THE CAR","CAR STORE",
True, Fields!T6_TOW_BY.Value
)

Conditionally Coloring Cells in SSRS

I am working on optimizing a report that I have in SSRS and am having some difficulty with a line of code. Essentially what I want is for a check to be made if the cell is blank, or if it has data. If it is blank I need the cell color to change to red. If it has data I need it to stay transparent. Here is what I have written.
=iif(Isnothing(Fields!MedServices.Value)= "True", "Red", iif(Isnothing(Fields!MedServices.Value)= "False", "Transparent"))
When I go to save this though I get the below error:
The BackgroundColor expression for the text box ‘MedServices’ contains
an error: [BC30455] Argument not specified for parameter 'FalsePart'
of 'Public Function IIf(Expression As Boolean, TruePart As Object,
FalsePart As Object) As Object'.
I know this must be a stupid error on my part with parenthesis, but I cannot figure out where I have made the error. Any help is appreciated.
IsNothing() function returns a boolean data type, true or false it is a valid expression for the IIF() function.
Try:
=iif(Isnothing(Fields!MedServices.Value) or Fields!MedServices.Value="",
"Red", "Transparent")

Conditional concatenation breaks if value is nothing

I'm trying to concatenate a string on the end of a sum, but if the sum is nothing, it breaks. It seems like this is due to SSRS evaluating both conditions of the IIf statement, but I can't figure out how to get around this.
I've got....
=IIf(IsNothing(Sum(Fields!Work.Value)), "", Sum(Fields!Work.Value).ToString + " J")
Which will print out the work summary + " J" if there is one, and #Error if not. What's the SSRS workaround?
Update / Clarification
The report in question is grouping on dates and then summing up Work, so it's not the case that Work is null, per se, but that for this particular date for this particular user, there are no rows in the group.. So, there are no rows to sum up in the error causing instance.
Sample Data Set
Name Date Work
Andy 12/1/15 511.30
Andy 12/1/15 549.70
Drew 12/2/15 484.80
Drew 12/2/15 322.36
Sample Report (current)
Name 12/1/15 12/2/15
Andy 1061 J #Error
Drew #Error 807.16 J
Sample Report (expected)
Name 12/1/15 12/2/15
Andy 1061 J
Drew 807.16 J
Have you considered doing the two parts of your desired output in two different expressions in the same Cell?
I assume for the current structure you have used a matrix, with Rows for the Name, and Columns for the date. You can the set the Data to be Sum of Work, as shown here, and in the red text in the image below.
=Sum(Fields!Work.Value)
You then then right click the cell and select "Create Placeholder" to insert a second expression in the same cell.
Set the value of this expression to be as shown here, and in the blue text below
=iif(Sum(Fields!Work.Value) > 0, " J", "")
Then when the report is run, it will always show the Sum if there is one, and if the value of the Sum is greater than zero, it will also display the J as required.
Hopefully this is the behaviour you require. Please let me know if you require further assistance with this solution
Try this:
=IIF(SUM(IIF(Isnothing(Fields!Total.Value),0,Fields!Total.Value)) = 0,
"",
SUM(IIF(Isnothing(Fields!Total.Value),0,Fields!Total.Value)).ToString + " J"
)
Let me know if this can help you
IIF does not short-circuit so this #Error is from SSRS trying to use the ToString function on NULLs.
The workaround is to add another IsNothing check in the false section before using ToString:
=IIF(IsNothing(Sum(Fields!Work.Value))
, ""
, IIF(IsNothing(Sum(Fields!Work.Value)), "", Sum(Fields!Work.Value)).ToString & " J")
To solve this exact problem, because if there is no Work to display then the report should display nothing, instead of using the IIf statement with concatenation, it is simple and sufficient to set a conditional visibility on the cell.
In the cell, use the expression:
Sum(Fields!Work.Value).ToString + " J"
Then for the same cell, select:
Text Box Properties > Visibility > Show or hide based on an expression
and enter:
=IsNothing(Sum(Fields!Work.Value))
While this solves this specific problem, if the solution requires the empty cell to display anything other than blank, then the original IIf short-circuit issue is still an issue.

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: