#Error in SSRS report

Jannette Jones 161 Reputation points

So i have a expression that calculates the variance percentage but when i run the report i get a #ERROR.
The equation is = = iif(Fields!mnyGPITotal.Value=0,"",Fields!Varriance.Value


Not sure how i can fix this.


SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,357 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Joyzhao-MSFT 15,471 Reputation points Microsoft Employee

    Hi @Jannette Jones ,
    Please try:

    =IIF((Fields!mnyGPITotal.Value = 0 or Fields!mnyGPITotal.Value  is nothing), "", Fields!Varriance.value/IIF(Fields!mnyGPITotal.Value = 0 or Fields!mnyGPITotal.Value is nothing, 1,( Fields!mnyGPITotal.Value)))  


    =IIF((Fields!mnyGPITotal.Value = 0), "", Fields!Varriance.value/IIF(Fields!mnyGPITotal.Value = 0, 1,( Fields!mnyGPITotal.Value)))  

    Or you can add a function in your custom code to handle division by zero:

     Public Function Divider (ByVal Dividend As Double, ByVal Divisor As Double)  
     If Is Nothing(Divisor) Or Divisor = 0  
        Return 0  
        Return Dividend/Divisor  
     End If  
     End Function  

    then call it in a cell like this:

    =Code.Divider(Fields!FieldA.Value, Fields!FieldB.Value)  

    Best Regards,

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments