# RDLC expression with CDEC conversion returns #Error RSS

Last post Jun 13, 2017 06:45 AM by zxj

Member

136 Points

433 Posts

### RDLC expression with CDEC conversion returns #Error

I have the following expression which should sum all the values and return total .This returns #Error at runtime for me. Please check my expression and help me what to be fixed:

`=IIF(CDec(Fields!AC3520.Value)>0,CDec(Fields!AC3520.Value),0)+IIF(CDec(Fields!C123.Value)>0,CDec(Fields!C123.Value),0)+IIF(CDec(Fields!C130.Value)>0,CDec(Fields!C130.Value),0)+IIF(CDec(Fields!C131.Value)>0,CDec(Fields!C131.Value),0)+IIf(CDec(Fields!C132.Value)>0,CDec(Fields!C132.Value),0)+IIf(CDec(Fields!MC1750.Value)>0,CDec(Fields!MC1750.Value),0)+IIf(CDec(Fields!MC2580.Value)>0,CDec(Fields!MC2580.Value),0)+IIf(CDec(Fields!MC2640.Value)>0,CDec(Fields!MC2640.Value),0)+IIF(CDec(Fields!MC3520.Value)>0,CDec(Fields!MC3520.Value),0)`

Thanks,

Deepak

Member

230 Points

209 Posts

### Re: RDLC expression with CDEC conversion returns #Error

Hi Deepak,

You may consider using a different approach.

You can write custom code that is used in expressions throughout a report.

Report Properties > Code and code a solution.

```Public Function Quotient(ByVal a As Decimal, b As Decimal) As Decimal
If ... Then
Return ...
Else
Return ...
End If
End Function```

To call the function

`=Code.Quotient(fields!FieldName.Value,Fields!FieldName2.Value)`

Adding Custom Code to a Report

https://msdn.microsoft.com/en-us/library/ms252130(v=vs.100).aspx

Regards,

zxj