Infopath xpath - preceding-sibling only showing first value, not preceding - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Infopath xpath - preceding-sibling only showing first value, not preceding

Last post 06-12-2019 08:12 AM by Hilary Stoupa. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-07-2019 09:01 AM

    Infopath xpath - preceding-sibling only showing first value, not preceding

    Good afternoon,

    I have a repeating section, where contains two relevant number fields. The first is where the user inputs a number, and the second totals it, adding that number with the previous total of the last section, placing it in this section's total.

    myFields
       yearrepeatpanel
          yearrpanel
              numberapproved
              totalnumapproved

    (xpath for totalnumapproved: my:myFields/my:yearrepeatpanel/my:yearrpanel/my:totalnumapproved)

    This is a repeating section, not table.

    I tried a bunch of xpath scripts to add them. However, each one adds the first section's total with the current number, instead of the previous section's total.

    For example, if I place the number 10 in the first section this sets the total (I made a condition for the first year) to 10. In the second section, I place 20, which sets the total to be 30 (as it should). However, by the third and subsequent section, it just adds the first total. So if I place 30, I am expecting 60, however, all I receive is 40. This keeps this way for all later sections.

    Of the xpaths that I used were:

    preceding::my:yearrpanel/my:totalnumapproved + ../my:numberapproved
    preceding-sibling::my:yearrpanel/my:totalnumapproved + ../my:numberapproved
    ../preceding::my:yearrpanel/my:totalnumapproved + ../my:numberapproved
    ../preceding-sibling::my:yearrpanel/my:totalnumapproved + ../my:numberapproved


    Thank you in advance,
    Shlomo
  • 06-11-2019 08:25 AM In reply to

    Re: Infopath xpath - preceding-sibling only showing first value, not preceding

    Here's a sample - save locally, right click & select design, then preview. I'm just summing the previous numberapproved and adding in the current in mine. I think for your schema the formula for the default value for totalnumberapproved would be: sum(../preceding-sibling::my:yearrpanel/my:numberapproved) + ../my:numberapproved
    Hilary Stoupa

  • 06-11-2019 08:17 PM In reply to

    Re: Infopath xpath - preceding-sibling only showing first value, not preceding

    Thank you Hilary,

    It worked like a charm, and gave me an overall understanding of preceding siblings.

    I have been reading and using your information for years, and am a big fan.

    Thank you,
    Shlomo
  • 06-12-2019 08:12 AM In reply to

    Re: Infopath xpath - preceding-sibling only showing first value, not preceding

     Here's a blog post from Greg Collins from back in 2005 that I still refer to for help with the preceding-sibling axis, in case it is helpful for you as well: https://www.infopathdev.com/blogs/greg/archive/2005/06/13/Using-XPath_2700_s-_2700_preceding_2D00_sibling_2700_-Axis-Correctly.aspx

    Hilary Stoupa

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