How to do mathematical operations - InfoPath Dev
in

InfoPath Dev

How to do mathematical operations

Last post 07-10-2006 07:12 PM by Matt Faus. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 04-19-2006 11:27 AM

    • fgaona
    • Not Ranked
    • Joined on 04-19-2006
    • Mexico
    • Posts 5

    How to do mathematical operations

    Hi I need to do mathematical operations with fields like plus/minus operations, but when in the field properties->value I wrote a formula like d:psalary-d:asalary. This expression is not a valid formula, so I want to know how can I do this formula.
    Thanks
  • 04-19-2006 12:56 PM In reply to

    Re: How to do mathematical operations

    Hi FG,

    you need to use number function for your psalary and asalary. ie. number(psalary)-number(asalary). Be sure to insert function number before you select your fields name.
    Stephanie Cantwell / Test Manager
    Qdabra® Software / Streamline data gathering to turn process into knowledge

  • 04-19-2006 04:20 PM In reply to

    • fgaona
    • Not Ranked
    • Joined on 04-19-2006
    • Mexico
    • Posts 5

    Re: How to do mathematical operations

    Hi Stephanie
    Thank you very much for your help, you advice is just I needed, but now I have a second trouble, when I run (Preview) my form it sends me a red square with "NaN"(My Infopath is in Spanish).
    And the problem that Infopath sends say like:
    "The XML squema can´t validate the archive.

    Union doesn´t admit the value.
    It can´t analize the attribute 'snvariacion' with the value 'NaN'.
    where 'snvariacion' is the field where I want to apper the result of the operation number(psalary)-number(asalary).
    I appreciate if you have an other wonderful tip like the other.

    quote:
    Originally posted by scantwell

    Hi FG,

    you need to use number function for your psalary and asalary. ie. number(psalary)-number(asalary). Be sure to insert function number before you select your fields name.

  • 04-19-2006 09:42 PM In reply to

    Re: How to do mathematical operations

    Hi,

    Place 0 as the default value for the fields psalary and asalary and u wont get NaN anymore.

    Regards,
    Abhishek
  • 04-20-2006 09:50 AM In reply to

    • fgaona
    • Not Ranked
    • Joined on 04-19-2006
    • Mexico
    • Posts 5

    Re: How to do mathematical operations

    Thanks Abhishek
    quote:
    Originally posted by Abhishek

    Hi,

    Place 0 as the default value for the fields psalary and asalary and u wont get NaN anymore.

    Regards,
    Abhishek

  • 04-20-2006 11:29 AM In reply to

    • fgaona
    • Not Ranked
    • Joined on 04-19-2006
    • Mexico
    • Posts 5

    Re: How to do mathematical operations

    Dear Abhishek
    your solution was close to solved my problem but if I place 0 as Default value, I dont´t know why but althought I put a formula in the data validation, this don´t recalculate the value with the formula for the field. I try to put the formula as a rule and in data validation but nothing happend
    Regards

    quote:
    Originally posted by Abhishek

    Hi,

    Place 0 as the default value for the fields psalary and asalary and u wont get NaN anymore.

    Regards,
    Abhishek

  • 04-21-2006 12:09 AM In reply to

    Re: How to do mathematical operations

    Hi,
    Can u give me some more details regarding what u r trying to do?
    regards,
    Abhishek
  • 04-25-2006 10:46 AM In reply to

    • fgaona
    • Not Ranked
    • Joined on 04-19-2006
    • Mexico
    • Posts 5

    Re: How to do mathematical operations

    Dear Abhishek my problem was more for data types, so I try to do my formulary in excel, but if I could´t I will like to send you and email with more details for help.
    Thank you and see you for now.
    quote:
    Originally posted by Abhishek

    Hi,
    Can u give me some more details regarding what u r trying to do?
    regards,
    Abhishek

  • 07-10-2006 11:34 AM In reply to

    • tricia
    • Not Ranked
    • Joined on 06-12-2006
    • Canada
    • Posts 3

    Re: How to do mathematical operations

    I'm in a similar kayak... in Preview Form I continue to receive NaN in the Client_Age field as soon as the application-date picker is used, and the Client_Age formula does not update when the Client_DOB is entered (yes, that check box is checked).

    This simplest of simple formulas is to calculate the age based on application date less the DOB:
    (((Application_date)) - ((Client_DOB))) div 365.25

    I changed my default values to zero, didn't help nor did using the number function. This should be a no-brainer...
    Tricia in Canada
  • 07-10-2006 07:12 PM In reply to

    Re: How to do mathematical operations

    Hi Patricia,

    A little generous with those parentheses, huh? I think your problem is that you are trying to subtract date fields. I am pretty sure that this will almost always result in NaN, b/c IP treats date fields almost the same as strings. You will have to do calendar arithmetic in code.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.