Logical AND Operator - InfoPath Dev
in

InfoPath Dev

Logical AND Operator

Last post 12-19-2013 07:31 AM by Hilary Stoupa. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 12-18-2013 11:38 AM

    • jedlo
    • Not Ranked
    • Joined on 12-18-2013
    • Posts 3

    Logical AND Operator

    I have a form that uses a repeating group, and a totals section to tally selections in the repeating group rows. For example, the repeating group has two check boxes, dataMSM and dataTested. Above the repeating group, there are three fields totalMSM, totalMSMTested and totalTested. The totalMSM and totalTested fields are set to increment like this:

    count(dataMSM[. = "yes"])
    count(dataTested[. = "yes"])

    These both work perfectly. Each time a row is added and these check boxes are checked, the correct fields increment by one. However, the totalMSMTested field should only increment if both dataMSM AND dataTested are checked. I've tried the following and each fails the validation:

    count(dataMSM[. = "yes"] and dataTested[. = "yes"])
    count((dataMSM and dataTested)[. = "yes"])
    count(((dataMSM) and (dataTested))[. = "yes"])


    Any ideas on how I can get the totalMSMTested field to increment only if both dataMSM AND dataTested are checked?

    Thanks!
  • 12-18-2013 06:01 PM In reply to

    Is this the full XPath? Can you check the Edit XPath box in the formula editor?

    At any rate, I'd think you want to count the rows where the values are true - without knowing the XPath to your nodes, I have to make something up here, but I'd expect something like:

    count(groups/group[dataMSM = 'yes' and dataTested = 'yes'])

    So, in the formula editor, select the repeating group. Add a filter, and the filter would be that dataMSM is yes and dataTested is yes - does that make sense?

    Hilary Stoupa

  • 12-19-2013 07:06 AM In reply to

    • jedlo
    • Not Ranked
    • Joined on 12-18-2013
    • Posts 3

    Thanks for the reply Hilary. I tried building a new formula from your example, but didn't have much luck. Here is the full XPath from one of my previous attempts:

     count(../my:group1/my:group2/my:dataMSM = "yes" and ../my:group1/my:group2/my:dataTested = "yes") 

    This throws the error: "Argument 1 must return a node-set." 

  • 12-19-2013 07:13 AM In reply to

    Try this - I'm assuming you picked your fields with the field picker so the ../my:group1/my:group2 relative path is correct:

    count(../my:group1/my:group2[my:dataMSM = "yes" and my:dataTested = "yes"]) 

    Hilary Stoupa

  • 12-19-2013 07:20 AM In reply to

    • jedlo
    • Not Ranked
    • Joined on 12-18-2013
    • Posts 3

     That worked! Thanks for your help!

  • 12-19-2013 07:31 AM In reply to

    Hooray! so what that XPath says is:

    Count the instances of the group2 node where inside that node both of these fields are equal to yes.

    Hilary Stoupa

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.