Solution for Division By Zero Exception in RTC Report Layout Expression

If you have an expression that results in division by zero of RTC report layout, then the result will show as #Error. You can write a VB function to avoid this issue. So follow the below steps.

  • First, you must write the following function in the RTC report. Open the report layout and go to the Code section of report properties, then add the following function in the Code section.
Public Shared Function DivideByValue(ByVal DivValue As Decimal, ByVal DivByValue As Decimal) As Decimal
If DivByValue = 0 Then
Return 0
End If
Return (DivValue / DivByValue)
End FunctionCode language: PHP (php)
  • After creating the above function you can call it in the expression as you need. The following example will show, how to call this function in the expression of report layout.
=Code.DivideByValue(Fields!TotAmt.Value,Fields!Quantity.Value)

Visit the previous tutorial about, how to convert Decimal to Text with rounding decimal places & thousand separators.

Senior Solutions Architect - Microsoft Dynamics Navision / Microsoft Dynamics 365 Business Central and freelance developer. (The admin of NAVUSER)

Leave a Comment