Subtracting Expressions (Report Builder 3.0) - reportbuilder3.0

I have 2 expressions to fill in the column for the current amount and prior amount:
Current Amount: =IIf(Fields!ACCOUNTING_PERIOD.Value = Parameters!AP.Value, Fields!DEPR.Value, "")
Prior Amount: =IIf(Fields!ACCOUNTING_PERIOD.Value = Parameters!PRAP.Value, Fields!DEPR.Value, "")
What I need to is complete a 3rd column (called "Diff) by subtracting the value in the prior amount field from the value in the current amount field.
I tried to use the following expression that subtracts 1 from the other to get the difference:
=(=IIf(Fields!ACCOUNTING_PERIOD.Value = Parameters!AP.Value, Fields!DEPR.Value, 0)) – (=IIf(Fields!ACCOUNTING_PERIOD.Value = Parameters!PRAP.Value, Fields!DEPR.Value, 0))
However, I get the following errorm message:
The Value expression for the textrun ‘Textbox6.Paragraphs[0].TextRuns[0]’ contains an error: [BC30037] Character is not valid.
FYI, Textbox6 is the cells where this expression resides. Any help in correcting this expression would be greatly appreciated. Thanks for your help.

I think there are two Problems with your diff expression.
First i would take away some equal signs:
=IIf(Fields!ACCOUNTING_PERIOD.Value = Parameters!AP.Value, Fields!DEPR.Value, 0) – IIf(Fields!ACCOUNTING_PERIOD.Value = Parameters!PRAP.Value, Fields!DEPR.Value, 0)
The second thing is, that according to the error message your Fields seem to formatted as characters not doubles. So you will need to convert them before substracting them. You should already do this in your sql-code with:
CONVERT(Fields!DEPR.Value AS numeric)
Hope this helps

Related

Sum expression in report Buildr

I got this expression
=iIF(Isnothing(Fields!Saldo_contable.Value) or (Fields!Saldo_contable.Value)<0,0,Fields!Saldo_contable.Value)
That works fine, I need to sum the result of the whole expression
=sum(iif(Isnothing(Fields!Saldo_contable.Value) or (Fields!Saldo_contable.Value)<0,0,Fields!Saldo_contable.Value)),
i dont get an actual error but the field just show the result: #Error,
What im doing wrong?
If Saldo_contable is not an integer, you need to use CDEC(0) for the zero value (2nd argument) of the IIF.
=SUM(IIF(Isnothing(Fields!Saldo_contable.Value) or (Fields!Saldo_contable.Value) < 0, CDEC(0), Fields!Saldo_contable.Value))
SUMming values like 0 and 2.25 results in a Can't sum different data type error.
Your detail line works because it isn't using SUM - just displaying the values.

Trying to generate an expression from a table based on table values

My SSRS report creates a summarized table. I need to do a calculation based on 2 pieces of data from the table and add it as an expression at the bottom of the report. My expression errors out as it is not reading the data output from the table.
I have followed up on all examples I could find with the error I get, but found no resolution. I am new to SSRS. I have tested the expression by simply using the IIf statement to return the values I'm looking for (without the rest of the calculations I need) and it doesn't return either value. I get "#Error" as the result. I have copied the lookup values directly from the SQL code, so I KNOW there are no typos in my comparison values.
I have this for the code in my expression:
=Code.Divide
(IIf(Fields!Results.Value = "BKR3 - Total Overtime Hours", Fields!Results.Value, 0)) ,
(IIf(Fields!Emp_Type.Value = "BKR1 - Total Paid Hours", Fields!Results.Value, 1))
Through another stackoverflow question I found this code and have added it to my report:
Public Function Divide(ByVal dividend as Double, ByVal divisor as Double) As Double
If IsNothing(divisor) Or divisor = 0 Or IsNothing(dividend) Or dividend=0 THEN
Return 0
Else
Return dividend/divisor
End If
End Function
I am getting this error:
The Value expression for the textrun
‘Textbox3.Paragraphs[0].TextRuns[0]’ contains an error: [BC30455]
Argument not specified for parameter 'divisor' of 'Public Function
Divide(dividend As Double, divisor As Double) As Double'.
This is what my output looks like:
*Emp_Type Results
*A3-Facility Payroll Hours 28,252.20
*A4-Provider Payroll Hours 1,998.50
*BKR1-Total Paid Hours 30,250.70
*BKR2-Total Worked Hours 27,037.62
*BKR3-Total Overtime Hours 504.20
*BS1-Hospital FTEs 99.72
*BS2-Clinic FTEs 23.25
Overtime % #Error
(I'm very sorry, I cannot get the list to indent!)
I am expecting this as my results:
Overtime % 0.18%
This is what I am getting instead:
Overtime % #Error

SSRS - Filtering an Integer With Both a String and a Boolean Parameter

I have a Boolean parameter called WLH where if True then it should ignore everything but if False then it should show a 0 for every craft textbox in a row that has the word "LABORER" in it. This is the expression that I am using but it doesn't seem to be doing anything. Can I get help on making it work? What am I doing wrong?
=IIF(Parameters!WLH.Value = false AND ReportItems!craft.Value LIKE "*laborer*", 0, ---main calculation for the else statement---)
Two things I see with this expression that need closer attention.
Parameters!WLH.Value = CBool("false"): The false side of the equality test needs to be converted to a boolean type with the CBool (conver to boolean) function.
ReportItems!craft.Value.IndexOf("laborer") >= 0: SSRS doesn't support LIKE in expressions but we can test for the existance of a substring in this manner. What this is doing is looking for the index (where the string "laborer" starts) in the field value and checking for a value greater than 0. This would mean that "laborer" was found while a value other than a positive integer means that the string "laborer" was not found.
I don't have SSRS installed on this machine to double check so post a comment if you still need help. Also note that IndexOf is case sensitive and that if you want to match to "Laborer" as well, you will have to do a case conversion prior to the IndexOf.
Full expression:
=IIF(Parameters!WLH.Value = CBool("false") AND ReportItems!craft.Value.IndexOf("laborer") >= 0, 0, ---main calculation for the else statement---)
EDIT: To deal with case sensitivity
Use "UCase()" to convert your field to upper case and then test only against "LABORER".
=IIF(Parameters!WLH.Value = CBool("false") AND UCase(ReportItems!craft.Value).IndexOf("LABORER") >=0, 0, ---main calculation for the else statement---)

Error on RDLC Expression

I am using this exp to calculate total fees paid on RDLC report:
=Sum(IIf(Fields!ResponseDescription.Value ="Approved Successful",Int(Fields!Amount.Value), 0))
And i get the #ERROR in the resulting column , what can be the issue ? .
And similar Exp above it work fine :
=Sum(IIf(Fields!ResponseDescription.Value <> "",Int(Fields!Amount.Value), 0))
Few notes:
1- Amount is always INTEGER and present.
2- ResponseDescription is always a STRING and present.
Thank you
You can use this expression:
=Sum(CInt(IIf(Fields!ResponseDescription.Value ="Approved Successful", Fields!Amount.Value, 0)))
You have to convert every possible values to the same type before aggregation.
I think the second expression works fine because you are always in the True case (Fields!ResponseDescription.Value <> "") so it always used an expression already converted to Integer.

What makes Crystal ignore record selection formula?

Crystal 2008. Have record selection formula ending with
and
( ( "Zero" in {?Credit_Debit} and {V_ARHB_BKT_AGING_DETAIL.AMOUNT} = 0)
or ( "Credit" in {?Credit_Debit} and {V_ARHB_BKT_AGING_DETAIL.AMOUNT} < 0)
or ( "Debit" in {?Credit_Debit} and {V_ARHB_BKT_AGING_DETAIL.AMOUNT} > 0) )
but no matter what combination of values is selected for Credit_Debit the result set is the same.
Also without success, I tried joining the parameter array into a single string and using lines like
or ( {#Cred_Deb_Choices} like "*Credit*" and {V_ARHB_BKT_AGING_DETAIL.AMOUNT} < 0)
Using the first method works in the same formula when the parameter values are integers, as:
and ({?Location ID} = 0 or {V_ARHB_BKT_AGING_DETAIL.LOC_ID} in {?Location ID})
I examined the generated SQL, and saw that the part at the beginning that had no effect was not shown.
I changed a part that tested for a hard-coded value to instead test for a parameter value, and looked at the SQL again. No change.
When you try to create a filter that doesn't fit with the datatype of the field then that doesn't get reflected in record selection formula.
For Integer field give integers in record selection for text give text.
E.g:
ID=0 and Name='XXX' works
ID='Zero' and Name='XXX' doesn't
This should solve your issue

Resources