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 6:18AM
    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 6:18AM
    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: »
    Mr.TNT wrote: »
    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])]

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.