IIF Syntax

I am attempting to prevent a divide by 0 error in the group footer of my report using
[IIF([grpTotSales]=0,0,[grpTotShrinkValue]/[grpTotSales])]
where grpTotSalse and GrpTotShrinkValue are Totals used in the Report

if grpTotSales is 0, the report generates an error and will not run

An unhandled exception of type 'System.Exception' occurred in FastReport.dll
Additional information: Text182: Error in expression: IIF([grpTotSales]=0,0,[grpTotShrinkValue]/[grpTotSales])

Can anyone provide the proper syntax.

Comments

  • edited 1:24AM
    I am attempting to prevent a divide by 0 error in the group footer of my report using
    [IIF([grpTotSales]=0,0,[grpTotShrinkValue]/[grpTotSales])]
    where grpTotSalse and GrpTotShrinkValue are Totals used in the Report

    if grpTotSales is 0, the report generates an error and will not run

    An unhandled exception of type 'System.Exception' occurred in FastReport.dll
    Additional information: Text182: Error in expression: IIF([grpTotSales]=0,0,[grpTotShrinkValue]/[grpTotSales])

    Can anyone provide the proper syntax.


    Hi,

    which .NET language is set in your report? C# or VB?

    For C# the expression should look like this [IIf([grpTotSales] == 0, 0, [grpTotShrinkValue]/[grpTotSales])]

    For VB it should be like yours: [IIf([grpTotSales] = 0, 0, [grpTotShrinkValue]/[grpTotSales])]
  • edited 1:24AM
    Thanks for your reply, I am using VB.Net, but the code does not work. I tried it with C#, but no go.

    I did change the statement to IIF([grpTotSales]=0,0,1) , which ran correctly, so the error is in the [grpTotShrinkValue]/[grpTotSales] expression

    Bill
    Mr.TNT wrote: »


    Hi,

    which .NET language is set in your report? C# or VB?

    For C# the expression should look like this [IIf([grpTotSales] == 0, 0, [grpTotShrinkValue]/[grpTotSales])]

    For VB it should be like yours: [IIf([grpTotSales] = 0, 0, [grpTotShrinkValue]/[grpTotSales])]

Leave a Comment