Function 'xdMath:Avg()' has failed in Infopath 2010 with SharePoint 2010 RRS feed

  • Question

  • I have a Infopath Form with Code base.

    While deleting a repeating section, it gives the error.

    In the logs, I got the error below:

    There was a form postback error. (User:  Form Name:  IP: , Request:  Form ID: urn:schemas-microsoft-com:office:infopath:CLW-Optimization-6:-myXSD-2011-04-13T13-18-14, Type: XPathException, Exception Message: Function 'xdMath:Avg()' has failed. Unable to cast object of type 'Microsoft.Office.InfoPath.Server.Xml.XPath.InfoPathXmlElement' to type 'System.Xml.XmlDocument'.) edebf1c8-a1a3-4369-a8a8-573ed5a3b61c

    I am using the Infopath fields and the calculated values as a column in the repeating table, which is having the formula:

    ((avg(WkndFnlAmb) * AmbPer) + (avg(WkndFnlFrzn) * FrznPer) + (avg(WkndFnlBatFrzn) * BatFrznPer) + (avg(WkndFnlCombo) * ComboPer) + (avg(WkndFnlCld) * CoolPer))


    When I am deleting the other repeating section, it will cause these values WkndFnlAmb, WkndFnlFrzn etc to be null which cause these 'xdMath:Avg() functions to get failed and cause the error.


    Please let em know how can I handle these exception by rules so that these Avg Functions did not throw any exception.



    Wednesday, November 28, 2012 5:53 PM

All replies

  • Hi Shaif,

    Thank you for posting in the MSDN Forum.

    I'll involve some experts who are more familiar with your issue. This may take some time.

    Thank you for your patient and understanding.

    Best regards,

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, November 29, 2012 9:20 AM
  • Hi,

    Any Updates??


    Friday, December 14, 2012 10:41 AM
  • Hi Shaif,

    I have not tested this out, but one thought I had was to check to see how many rows there were prior to deleting the last one.  If you are about to delete the last one, add a blank row in the table to prevent the calculated column from receiving a null value.

    Hope this helps!

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Ian Kavanagh
    Microsoft Online Community Support

    Thursday, December 27, 2012 9:20 PM
  • Hi shaif

    below link might help you


    Sunday, January 6, 2013 7:30 PM