Math Problem - InfoPath Dev
in

InfoPath Dev

Math Problem

Last post 11-07-2013 09:36 AM by smonczka. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 11-05-2013 08:54 AM

    Math Problem

    Having an issue trying to write a formula for a field.

    I have three cells A B C

    A = Hours for Job 1 (there will always be a number in this field)

    B = Hours for Job 2 (there may not be an entry for this field)

    C = A + ((B+A) /.5)

    The issue comes in when there is no entry for field B (B =0).  Then I get NaN because you can't divide by 0. 

    Thanks 

  • 11-05-2013 03:40 PM In reply to

     It doesn't appear to me that this would be a divide by zero error - you are dividing by .5, right? At any rate, maybe try adding an XPath filter on B.

    C = A + ((B[. != ''] + A) / .5)

    Hilary Stoupa

  • 11-05-2013 04:14 PM In reply to

    Hilary that worked, but I have developed another issue, unrelated to the first. 

     Field A / Field B = Field C 

    Returns Error "Infiniti"

    Not sure why this is happening. If A = 4 and B = 2   C should = 2 But I get an error.  If I go into the text box properties of C and put in the formula 4 / 2  it works.  But if I put in the properties of the text box (fieldA / fieldB) I get an error.

     

  • 11-05-2013 05:56 PM In reply to

     I'm confused - where are you putting the formula? As a default in Field A? B? C? Maybe attach a sample form and un-confuse me? :)

    Hilary Stoupa

  • 11-05-2013 06:14 PM In reply to

    Hillary I do need your help.  If you open the link below (I see no way of attaching files in this forum) you will see what the issue is. 

    There are several rows in the form just like this one.  The user checks off a row and then populates the number of unites.  The last field is the total of Hours / Units.  A rule runs when the check box is checked If True then total = Hours / Units.  If false then total = 0.   

    Example.xsn
  • 11-06-2013 07:05 AM In reply to

     When you reply to a post, one of the tabs is Options. You can attach a file under the Options tab. Here's your example back - I've added additional conditions and rules (checkbox & units field).

    Hilary Stoupa

  • 11-06-2013 04:08 PM In reply to

    Hilary, Thank you so much!  I see what you did but why did that fix it? Is it because the rules only run on update to the field.  So you would check off the box, the rule would run but there was nothing in the Unit field.  So you added the rules to the unit field so when the unit field is updated the rule runs again?

  • 11-06-2013 04:28 PM In reply to

     You got it. So - one thing it took me a while to understand but that is very important is that rules only execute when the field they are on changes. When you check the box, there is nothing in units. We don't want to run the rule if there is nothing in units, so we add a condition to protect about that. When you change units, if the box is checked, we want to run the same rule. So - the rule depends on Units & on the checkbox, thus the rule needs to be on both fields, and conditions need to take both fields into account. Make sense?

    Hilary Stoupa

  • 11-07-2013 09:36 AM In reply to

    Yes it makes total sence, thank you!
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.