Reputation: 83
I am working on a report and in one of the fields is
=(ReportItems!Textbox1.value-ReportItems!Textbox2.value) /(ReportItems!Textbox1.value+ReportItems!Textbox2.value)
which is the division of previous 2 fields and if i have any values for these fields then i get the correct value,but if i dont have any values for the previous 2 fields i mean if they are empty then it returns me #ERROR.
So finally i used VB.Net code like below
Public Shared Function VarPercent(ByVal Actual As Decimal, ByVal Budget As Decimal) As Decimal If Budget = 0 Then Return 0 End If Return (Actual / Budget) End Function
Use Expression as below
=code.varpercent(ReportItems!Textbox1.value-ReportItems!Textbox2.value) /(ReportItems!Textbox1.value+ReportItems!Textbox2.value) its worked nicely.
See My problem is When i try to add SUM of fields like below
=code.varpercent(sum(ReportItems!Textbox1.value-ReportItems!Textbox2.value)) /sum((ReportItems!Textbox1.value+ReportItems!Textbox2.value) )
Am getting #Error, Is it righr way to add sum function in expression? If yes,How can i use SUM function in above expression? Give any alterenate solutions?
Thanks,
Samba
Upvotes: 1
Views: 4003
Reputation: 1068
Try casting the values to the appropriate type (...Cint(), CDbl()...).
CDbl(ReportItems!Textbox1.value)
Upvotes: 7