Help: Divide by Zero Errors

Hi, can someone please advise me on how to avoid script failure alerts (like the one below), which are generated because certain calculations are being performed before any positive value has yet been set in a numeric field?
Here is an example of the calculation:
--- form1.SF_CalculationTable.acview[0]::calculate - (FormCalc, client) --
(ac[0] / tr[0]) * 100
Error example:
Script failed (language is formcalc; context is
xfa[0].form[0].form1[0].SF_CalculationTable[0].acview[0])
script=(ac[0] / tr[0]) * 100
Error: arithmetic over/underflow.
update: it appears these erros are "divide by zero" errors.
So my questions are,
(1) would I put any javascript (to override the zeros) on the "validate" event or the "calculate" event, and on which of the three fields in question, acview[0] (the result), tr[0] (the denominator) or ac[0] (the numerator). and...
(2) What might that javascript look like?
Harry

Your error message indicates your script is being executed as FormCalc, not JavaScript.
If you're using FormCalc try using an If statment to test for zero/null.
if (tr>0) then (ac/tr)*100 endif

Similar Messages

  • Arithmetic Overflow/Underflow and Divide by Zero Errors

    We're having problems similar to those posted below (see links), especially "Help: Divide by Zero Errors" to which no one has addressed. <br /><br />Here's our situation: On our form, we have two columns that sum the rows above them, called<br /><br />"covertotal" and "multtotal"<br /><br />...for which we need a final calculation: multtotal/covertotal<br /><br />Under calcutions in FormCalc, we have generated the following formula for the box called "prevtotal" under the calculate command: <br /><br />(multtotal / covertotal)<br /><br />However, since this calculation runs when the document is opened, we get a divide by zero error. Do we need to create an initialize or calculate formula to correct for this zero? If so, what is the proper coding.<br /><br />Please spell this out, we're that stupid... <sigh><br /><br />Thanks!<br /><br />Matthew<br /><br />Previous posts with similar problems are linked below:<br /><br />Help: Divide by Zero Errors<br /><a href="/cgi-bin/webx?14@@.3bbd2077">Harry Kontos, "Help: Divide by Zero Errors" #, 6 Nov 2005 10:01 pm</a><br /><br />calculations overflow/underflow<br />http://www.adobeforums.com/cgi-bin/webx/.3bbeb7e0<br /><br />FormCalc error-arithmetic overflow/underflow<br />http://www.adobeforums.com/cgi-bin/webx/.3bbc15f3

    Your error message indicates your script is being executed as FormCalc, not JavaScript.
    If you're using FormCalc try using an If statment to test for zero/null.
    if (tr>0) then (ac/tr)*100 endif

  • Divided by zero error

    All,
    I am having trouble with one of the reports in EBS.
    When I run the two underlying sql of the report in toad I get the data.
    But, when I ran the report from the application I was getting some oracle error.
    So, I ran the report directly from the reports builder to see what error I am getting.
    It turns out that I am getting divided by zero error.
    I am passing in the org id and gl dates an inputs the report.
    Please help me debug the report.

    Could you check if your report has any subquery that doesn't return any record when the parameters are submitted at run time.
    I had the issue in Crystal Reports where it threw a divide by 0 error.

  • SQL to avoid Dreaded "Divide by Zero" error

    Hey,
    I have been banging my head off the decode and NVL functions to avoid the divide by zero error, can tfor the life of me get it.
    2 columns, a & b.
    Need to get: a/b (but the whole thing fails if either is null or zero)
    Any help greatly appreciated.
    Dob

    VG2 wrote:
    You need something like
    decode( b, 0, to_number(null),
    b, null, to_number(null),
    a/b )What is that?
    in psuedo language with that statement you are saying...
    If b is zero then return to_number(null) (which is the same as null) else
    if b is null then to_number(null) (which is still null) else
    a/b
    surely it's just a case of saying
    nvl(a,0)/nvl(b,1)which assumes that if b is null it should not effect a and if a is null then the result should be zero.

  • Divide by zero error encountered

    Dear All,
    When our customer process PO, they got an error like below:
    Divide by zero error encountered. Tax definition [ovcg]
    They also got Divide by zero error encountered. Outgoing payments  [ovpm]
    They can process their business but we need to know why and how to fix this error for them.
    Any idea? Thanks.
    Regards,
    Yuka

    Hi,
    You need to check the FMS defined on the row level of the document you want to add.
    Remove the FMS and you will not get the error message reported.
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • Update Rules : Divide by zero error

    Hi All,
    I am calculating Condition Rate for billing using formula KWERT/FKIMG i.e. amount/quantity. Its giving me divide by zero error when FKIMG = 0.
    Can we prevent division by 0 error like we can do it in query formula uding NDIV0.
    Thanks
    PB

    Hi,
    you can write routine to avoid the error.
    if quantity <> 0.
      conditon rate = amount /quantity
    else
      conditon rate = space or zero (according to your requirement)
    endif.
    Message was edited by:
            Siva Chidambaram

  • Roxio "divide by zero" error

    I have printed a dozen or so DVDs using my HP 5200 series printer and the same ink-jet printable DVDs that I'm now trying to print to.  Now when I try to print I am getting a "divide by zero" error message and the software locks up.  The only way to regain control of the computer is touse task manager to shut the Roxio software down.  After restarting several times with same results I uninstalled/reinstalled the software from the HP installation CD and still am getting the error.
    First question is if someone has found a fix.  Second question is of someone has found good software for printing to discs usint the 5200 series printers.  I'm not satisfied with the Roxio product and certainly won't upgrade from the free version if I can't get it working.  I have Nero 7 but I don't believe it will work for printint directly to disc using the 5200 series printers.

    i'm having the exact same problem with the labeling software..... i would greatly appreciate an answer to this spoof-auf. i'm using 3.2.1.28 express  .... 

  • SSRS Expression divide by zero error

    Hi, I am getting an error in SSRS calculating the field that potentially divide by zero. may i ask your help to fix this issue. thanks.
    =First(Fields!CEQ_all.Value, "DailyUpdates_DS") = value is zero
    =Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")= value is 0.16
    --This is the codes in my field expression
    =IIF(First(Fields!CEQ_all.Value, "DailyUpdates_DS")>Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS"),Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")/First(Fields!CEQ_all.Value, "DailyUpdates_DS"),1)

    try like this
    =IIF(First(Fields!CEQ_all.Value, "DailyUpdates_DS")>Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS"),Sum(Fields!Prod_Plan_Yield.Value, "DailyUpdates_DS")/IIF(First(Fields!CEQ_all.Value, "DailyUpdates_DS")>0,First(Fields!CEQ_all.Value, "DailyUpdates_DS"),Nothing),1)
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • This Query IS giving divide by zero error when executed in sql plus

    UPDATE grn G
    SET g.OPT_WA_FAIR_VAL_A = (SELECT
    ROUND(SUM(NVL(ga.OPT_FAIR_VAL_A, 0) * NVL(gvs.GRN_VEST_OPT_Q, 0)) / SUM(NVL(gvs.GRN_VEST_OPT_Q, 0)), 6)
    FROM
    GRANT_VESTING_SCHEDULE gvs,
    GRANT_ASSUMPTION ga
    WHERE
    gvs.ORG_GRP_I = ga.ORG_GRP_I AND
    gvs.grn_n = ga.grn_n AND
    ga.ORG_GRP_I = g.ORG_GRP_I AND
    ga.GRN_N = g.GRN_N AND
    NVL(ga.GRN_ASMPN_EFF_D, gvs.grn_vest_d) <= gvs.grn_vest_d AND
    NVL(ga.GRN_ASMPN_END_D, gvs.grn_vest_d) >= gvs.grn_vest_d
    WHERE G.ORG_GRP_I =5
    Any suggestions

    hi
    What should be result if divide by zero e.g
    SQL> SELECT * FROM emp;
        EMPNO ENAME        JOB             MGR HIREDATE        SAL      COMM    DEPTNO
         7901 SMITH        CLERK          7902 17-DEC-80         0         0        20
         7499 ALLEN        SALESMAN       7698 20-FEB-81      2100      1800        30
         7521 WARD         SALESMAN       7698 22-FEB-81      2300      2000        30
         7566 JONES        MANAGER        7839 02-APR-81      1000      3000        20
         7654 MARTIN       SALESMAN       7698 28-SEP-81      3200       700        30
         7698 BLAKE        MANAGER        7839 01-MAY-81      1000      3000        30
         7782 CLARK        MANAGER        7839 09-JUN-81      1000      3000        10
         7788 SCOTT        ANALYST        7566 19-APR-87      1000      1900        20
         7839 KING         PRESIDENT           17-NOV-81      1000      1700        10
         7844 TURNER       SALESMAN       7698 08-SEP-81      1800       700        30
         7876 ADAMS        CLERK          7788 23-MAY-87      1000      1300        20
         7900 JAMES        MANAGER        7698 03-DEC-81      1000      3000        30
         7902 FORD         ANALYST        7566 03-DEC-81      1000      2000        20
    13 rows selected.
    SQL> SELECT sal/DECODE(comm,0,1,comm) FROM emp;
    SAL/DECODE(COMM,0,1,COMM)
                            0
                    1.1666667
                         1.15
                    .33333333
                    4.5714286
                    .33333333
                    .33333333
                    .52631579
                    .58823529
                    2.5714286
                    .76923077
                    .33333333
                           .5
    13 rows selected.Khurram

  • Divide by Zero encountered 'Withholding Tax'

    Good evening pro's
    I'm busy with a test upgrade to 8.8 SP00 PL14 and everything went successful, but in 8.8 when i open a sales order, i get an error message that says Divide by zero error encountered 'Withholding Tax'
    I put in the with holding tax in under financial setup and then the message disappears.  when i close sales orders and open it again, the message is back... how can i get rid of this message?
    I forgot to mention that this doesn't block to order / delivery / invoice to be processed at all.
    Thanks in advance,
    Reinhardt
    Edited by: R. Buytendorp on Oct 25, 2010 6:54 PM

    Hi Kate,
    Yes i've managed to sort out the problem.  One of our formatted searches was causing the issue.
    We have a formatted search on one of our fields that calculate an addition to the unit prices depending on what value (Value between 0 and 10) is chosen.
    The 0 in the field was causing this error to pop up as it was the default value for the field, so all i did was to edit the formatted search with a CASE WHEN <calculation> = 0 then 0 else <calculation>.
    The error does not pop up anymore.
    I hope this will help you...
    Reinhardt

  • Attempted to divide by zero. Error while executing the script

    Hi All,
    I using a script I found long back and I'm trying to use to get disk space info from different servers with separate credentials.
    I'm getting the below error and it has eaten my head but I'm not able to figure out where the problem lies in the code.
    Attempted to divide by zero.
    At D:\psscripts\ww.ps1:92 char:26
    + $freePercent = ($frspace/ <<<< $totSpace)*100
    + CategoryInfo : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException
    I'm open to use any other way to find me Disk Space with different credentials..here security isn't a question.
    This script uses computers.csv to reference the computer name and the referenced credentials in the script.
    Thanks in advance
    $freeSpaceFileName = "c:\script\FreeSpace.htm"
    $warning = 50
    $critical = 30
    New-Item -ItemType file $freeSpaceFileName -Force
    $ComputerList = Import-Csv -Path d:\Computers.csv;
    $CredentialList = @{
    Cred1 = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'laptop-pc\administrator', (ConvertTo-SecureString -String 'tamboli' -AsPlainText -Force);
    Cred2 = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'contoso\administrator', (ConvertTo-SecureString -String 'Atlantic12' -AsPlainText -Force);
    Function writeHtmlHeader
    param($fileName)
    $date = ( get-date ).ToString('dd/MM/yyyy HH:mm:ss')
    Add-Content $fileName "<html>"
    Add-Content $fileName "<head>"
    Add-Content $fileName "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
    Add-Content $fileName '<meta http-equiv="refresh" CONTENT="5">'
    Add-Content $fileName '<title>All Servers DiskSpace Report&copy;</title>'
    add-content $fileName '<STYLE TYPE="text/css">'
    add-content $fileName "<!--"
    add-content $fileName "td {"
    add-content $fileName "font-family: Tahoma;"
    add-content $fileName "font-size: 20px;"
    add-content $fileName "border-top: 1px solid #999999;"
    add-content $fileName "border-right: 1px solid #999999;"
    add-content $fileName "border-bottom: 1px solid #999999;"
    add-content $fileName "border-left: 1px solid #999999;"
    add-content $fileName "padding-top: 0px;"
    add-content $fileName "padding-right: 0px;"
    add-content $fileName "padding-bottom: 0px;"
    add-content $fileName "padding-left: 0px;"
    add-content $fileName "}"
    add-content $fileName "body {"
    add-content $fileName "margin-left: 5px;"
    add-content $fileName "margin-top: 5px;"
    add-content $fileName "margin-right: 0px;"
    add-content $fileName "margin-bottom: 10px;"
    add-content $fileName ""
    add-content $fileName "table {"
    add-content $fileName "border: thin solid #000000;"
    add-content $fileName "}"
    add-content $fileName "-->"
    add-content $fileName "</style>"
    Add-Content $fileName "</head>"
    Add-Content $fileName "<body>"
    add-content $fileName "<br></br>"
    add-content $fileName "<table width='100%' align=center>"
    add-content $fileName "<tr bgcolor='#CCCCCC'>"
    add-content $fileName "<td colspan='7' height='25' align='center'>"
    add-content $fileName "<font face='tahoma' color='#003399' size='5'><strong>All Servers DiskSpace Report &copy; - $date</strong></font>"
    add-content $fileName "</td>"
    add-content $fileName "</tr>"
    add-content $fileName "</table>"
    add-content $fileName "<br></br>"
    # Function to write the HTML Header to the file
    Function writeTableHeader
    param($fileName)
    Add-Content $fileName "<tr bgcolor=#CCCCCC>"
    Add-Content $fileName "<td width='10%' align='center'>Drive</td>"
    Add-Content $fileName "<td width='50%' align='center'>Drive Label</td>"
    Add-Content $fileName "<td width='10%' align='center'>Total Capacity(GB)</td>"
    Add-Content $fileName "<td width='10%' align='center'>Used Capacity(GB)</td>"
    Add-Content $fileName "<td width='10%' align='center'>Free Space(GB)</td>"
    Add-Content $fileName "<td width='10%' align='center'>Freespace %</td>"
    Add-Content $fileName "</tr>"
    Function writeHtmlFooter
    param($fileName)
    Add-Content $fileName "</body>"
    Add-Content $fileName "</html>"
    Function writeDiskInfo
    param($fileName,$devId,$volName,$frSpace,$totSpace)
    $totSpace=[math]::Round(($totSpace/1073741824),2)
    $frSpace=[Math]::Round(($frSpace/1073741824),2)
    $usedSpace = $totSpace - $frspace
    $usedSpace=[Math]::Round($usedSpace,2)
    $freePercent = ($frspace/$totSpace)*100
    $freePercent = [Math]::Round($freePercent,0)
    if ($freePercent -gt $warning)
    Add-Content $fileName "<tr>"
    Add-Content $fileName "<td>$devid</td>"
    Add-Content $fileName "<td>$volName</td>"
    Add-Content $fileName "<td>$totSpace</td>"
    Add-Content $fileName "<td>$usedSpace</td>"
    Add-Content $fileName "<td>$frSpace</td>"
    Add-Content $fileName "<td>$freePercent</td>"
    Add-Content $fileName "</tr>"
    elseif ($freePercent -le $critical)
    Add-Content $fileName "<tr>"
    Add-Content $fileName "<td>$devid</td>"
    Add-Content $fileName "<td>$volName</td>"
    Add-Content $fileName "<td>$totSpace</td>"
    Add-Content $fileName "<td>$usedSpace</td>"
    Add-Content $fileName "<td>$frSpace</td>"
    Add-Content $fileName "<td bgcolor='#FF0000' align=center>$freePercent</td>"
    #<td bgcolor='#FF0000' align=center>
    Add-Content $fileName "</tr>"
    else
    Add-Content $fileName "<tr>"
    Add-Content $fileName "<td>$devid</td>"
    Add-Content $fileName "<td>$volName</td>"
    Add-Content $fileName "<td>$totSpace</td>"
    Add-Content $fileName "<td>$usedSpace</td>"
    Add-Content $fileName "<td>$frSpace</td>"
    Add-Content $fileName "<td bgcolor='#FBB917' align=center>$freePercent</td>"
    # #FBB917
    Add-Content $fileName "</tr>"
    foreach ($computer in $ComputerList)
    Get-WmiObject -ComputerName $Computer.Name -Class Win32_LogicalDisk -Credential $CredentialList[$Computer.Credential] | Where-Object {$_.drivetype -eq 3}
    Write-Host $item.DeviceID $item.VolumeName $item.FreeSpace $item.Size
    writeDiskInfo $freeSpaceFileName $item.DeviceID $item.VolumeName $item.FreeSpace $item.Size
    writeHtmlHeader $freeSpaceFileName
    foreach($computer.Name in Get-Content Computers.csv)
    Add-Content $freeSpaceFileName "<table width='100%'><tbody>"
    Add-Content $freeSpaceFileName "<tr bgcolor='#CCCCCC'>"
    Add-Content $freeSpaceFileName "<td width='100%' align='center' colSpan=6><font face='tahoma' color='#003399' size='2'><strong> $server</strong></font></td>"
    Add-Content $freeSpaceFileName "</tr>"
    Add-Content $freeSpaceFileName "<br>"
    writeTableHeader $freeSpaceFileName
    Thanks,

    Hi Taher,
    You got the error "Attempted to divide by zero.", because the input variable $totSpace is null, please note the variable $item when you invoked the function writeDiskInfo:
    >>Get-WmiObject -ComputerName $Computer.Name -Class Win32_LogicalDisk -Credential $CredentialList[$Computer.Credential] |  Where-Object {$_.drivetype -eq 3}
    >>Write-Host  $item.DeviceID  $item.VolumeName $item.FreeSpace $item.Size
    >>writeDiskInfo $freeSpaceFileName $item.DeviceID $item.VolumeName $item.FreeSpace $item.Size
    And you haven't defined the variable $item before you used it, so please refer to the script below:
    foreach ($computer in $ComputerList)
    $items = Get-WmiObject -ComputerName $Computer.Name -Class Win32_LogicalDisk -Credential $CredentialList[$Computer.Credential] | Where-Object {$_.drivetype -eq 3}
    foreach($item in $items){
    Write-Host $item.DeviceID $item.VolumeName $item.FreeSpace $item.Size
    writeDiskInfo $freeSpaceFileName $item.DeviceID $item.VolumeName $item.FreeSpace $item.Size}
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Catching errors such as divide by zero and typing non-numeric characters

    Fellows: How do I extend following script to catch errors such as divide by zero and typing non-numeric characters.      Thanks
    This program takes two integers (whole numbers), then displays the sum, average, division,
    Modula of those numbers and finally the first number raised to the power of the second number.
    import java.io.*;
    public class HWOne
         public static void main(String[] args) throws IOException  // error handling
              // variable declaration
              String firstdigit, seconddigit;
              int first, second, sum, total, modus, power;
              float division;
              double average;
              BufferedReader myIn = new BufferedReader(new InputStreamReader(System.in));
              //Invoke user response
              System.out.print("Please enter first digit ");
                   firstdigit = myIn.readLine();
                   first = Integer.parseInt(firstdigit);
              System.out.print("Please enter second digit ");
                   seconddigit = myIn.readLine();
                   second = Integer.parseInt(seconddigit);
              //computations
              sum = first + second;
              average = (double)sum / (double)2;
              division = (float)first / (float)second;
              modus = first % second;
              power = (int)Math.pow(first, second);
              //Screen message
              System.out.println("Sum: " + sum);
              System.out.println("Average: " + average);
              System.out.println("Division: " + division);
              System.out.println("Modula: " + modus);
              System.out.println("Power: " + power);

    Have you learnt about try/catch statements yet?
    The parseInt method throws a NumberFormatException. So you place the call to that method inside a try statement and catch the exception.
    For divide by zero, you can use an if statement. If the divisor != 0 perform division.

  • At startup-system error and divide by zero

    I've been having a lot of problems starting up my beige G3 mini tower, it has 233mhz, 384ram, mac os9.1. I've zapped the pram and held the shift key down to boot with extensions off, didnt work. I've changed the battery twice in case the first replacement was bad, it started up and ran long enough for me to trash all the preferences, I tried to change the extensions, but when restarting it was back to not completely starting up. I've tried pressing the button near the pci slots with the battery out, 30 seconds, waited 30 minutes and held down the button for another 30 seconds, replaced the battery, checked the sound card for looseness then at startup it worked till I changed the time and date. I tried the battery and button again this time waiting over night between pressing the button for 30 seconds, after startup I was able to run disc first aid and it said everything was ok, then crashed again when I tried to change the date and time. I've even tried booting up from command/option/o/f, I'm not sure what firmware is but it would try to start up that way,but was very slow with a os cd in the cd drive. I tried to erase the hard drive but I couldnt get it to start up from a cd, iv'e tried os9, the original cd that came with the computer and a system recovery cd.
    Most times when trying to start it up it chimes, then the happy mac with a grey screen, then the mac os screen, then the bomb with "system error" and under that "bus error" under that it says to restart with extensions off. sometimes the button for restart will even work with the cursor. Once, after trying to start up after all the battery removal, pressing button near pci slots , pressing com/opt/o/f, extensions off, the screen getting to the mac os then the bomb dialogue, it said system error and instead of saying "bus error" it said "divide by zero". Thats the first and only time I've seen that one. Also, the grey screen (with the happy mac disc icon) now has horizontal lines with texture? that I havent noticed before.
    got any ideas what I should do next? I probably wouldnt bother with my G3 anymore because I just bought a new Imac, but I have a vinyl cutter hooked to it, it has the old round serial port cables and I would have to buy new software, cables and dongle to use it with my new Imac, I also have illustrator, photoshop, scanner, and drawing tablet on my G3 that I cant use on my new Imac (intel) leopard.
    Is my hard drive or motherboard dying? is there a way to find out if and what hardware is messed up? and if so, is there still still parts out there for this G3?

    Hi, R1camper -
    I ran disc first aid from the cd and and it said it couldnt fix-overlapped extent allocation,4,479.
    That is a type of disk directory damage, one which Disk First Aid can not repair.
    Alsoft's DiskWarrior can usually repair that kind of damage, with no loss of files. If you choose to go this route, suggest you call (or email) Alsoft's sales department, and request an older version of DiskWarrior - the current versions won't run on your Beige G3/MT.
    However, if you can manage to live with the loss of files, you can probably replace the hard drive for less cost.
    Your Beige G3/MT came with either an ATA (now often referred to as PATA and/or IDE) drive or a SCSI drive - it could have been ordered with either when the machine was new.
    With luck it will be an ATA drive, since those are the least expensive and the easiest to install. Such drives are not Mac-specific - any ATA drive designed for internal use and of appropriate size will work. The only item of concern is to set the drive's jumpers properly. The drive should be jumpered as Master (it may come preset as Master or as Cable Select - Cable Select will not work on your model), unless it is a Western Digital in which case it should be set to Single if that is an available choice.
    There is probably little to gain by getting a 7200RPM drive, especially if there is extra cost for one vs. a 5400RPM drive - the relatively slow internal bus speed on your machine will not be able to take significant advantage of a faster drive.
    Re the RAM, if you have the time you might try replacing any you took out. Over time the contact the module makes in its slot can get iffy - removing and replacing the module usually fixes that problem, by wiping the contacts clean.

  • #Error using IIF and divide by zero

    I am getting an error in a calculated field that could potentially divide by zero, even though I'm using an IIF.  The column displays in the report as "#Error".  My expression looks like this:
    = IIF(Fields!Qty.Value = 0,
    "None", Fields!Hours.Value / Fields!Qty.Value)
    I have successfully used this approach with INT fields, but this time the Hours field is a NUMERIC(9,2).  My workaround is to do this:
     IIF(Fields!Qty.Value = 0, "None", IIF(Fields!Qty.Value = 0, 42, Fields!Hours.Value) / Fields!Qty.Value)
    I guess the 42 is cast to an INT inside the second IIF and the calculation works.
    What's strange is that the division would even be carried out in the event of Qty = 0 from the first IIF, because the expression should just evaluate to "None" and that would be that.
    Has anybody run into this problem?  Is my workaround the recommended approach?
    -Larry

    First a diatribe: This is just one of the many annoying "features" of SSRS that needs to be fixed. It should just flat out work. Period.
    Now the fix.
    The following formula to calculate Discount% gives the #Error result if List = 0
    =iif(Fields!List.Value=0,0, (Fields!List.Value-Fields!Net.Value)/Fields!List.Value)
    However, if you add a very small number to the divisor it will work.
    =iif(Fields!List.Value=0,0, (Fields!List.Value-Fields!Net.Value)/(Fields!List.Value+.000001))
    Apparently SSRS evaluates the false part of the expression before it tests. Try this in most any other language and you will not have this problem.
    You just need to add a small enough number to your formula to not impact your results when the divisor is not zero.
    You can actually leave out the IIF entirely if you do this:                             
    Fields!List.Value-Fields!Net.Value)/(Fields!List.Value+.000001)
    I usually leave the syntax in there just so I know what the intention was.

  • Percentage calculation and zero amount entries get dvision by zero error

    Hello, i am calculating the total of a field and then reporting the contributions of that line entry in percentage form but when a line has a zero amount i get an error of 'division by zero'.  I'll give some explamples below incase i'm not explaining very well.  If you replace the 225 under amount with 0 that is when i get the error.
    code sample..
    WhilePrintingRecords;
    numbervar n := {@Total Weight}% Sum ({@Total Weight}, {JSALES_REPORT.SOPNUMBE});
    data sample...
    Amount      % of total
    150             40%
    225             60%
    (375)

    Hi Rod.
    I'd recommend using and IF statement to deal with division by zero.  I'm not sure what you exactly want to do with records that have division 0 but I usually do the following to see which records are creating the div by zero errors and then decide how I want the values to be displayed after evaluating it.
    WhilePrintingRecords;
    if {whichever.field} = 0 then 9999999999  // this would be an indicator to me to take a look at this record
    else
    numbervar n := {@Total Weight}% Sum ({@Total Weight}, {JSALES_REPORT.SOPNUMBE}); // your original formula
    You can then change the 99999999 number to whichever number you think should be viable to answer your business question on items that are divided by 0.
    Hope this helps.

Maybe you are looking for

  • Lock object funtion module for afpo table

    Hii, I have designed a screen and maintained batch field as mandatory field in that screen. and when i give batch number and hit enter the order number related to that batch number is automatcially picked. order and batch field's i am taking from AFP

  • How to increase no. of decimal places in a cube

    Dear Friends Can you tell me how to increase no. of decimal places in a cube i want 5.98765 this value in the keyfigure but it is allowing me only 5.987 only 3 digits after decimal urgent Thx

  • Commiting weardness

    I am using struts, jsp and frames and have problems with inserting records. There are some strange things happening. For example, the commit button is enabled the first time I run my jsp application, before any insert is done. Why? When inserting a r

  • Flash player install...

    Ok. First post and it is *not* a serious post. After years of installing updates to the flash player, I wish the programmers would do something like the below manipulated screen shot. Take care, Mike

  • Transfer modified Org structure

    I have been able to successfully transfer the org structure from our CRM dev environment to CRM quality environment using the RHMOVE30 report. But, know I have made some changes to the org structure in the dev environment. Changes include addition of