sum preceding nodes in repeating sections - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

sum preceding nodes in repeating sections

Last post 01-30-2024 07:56 AM by stevec. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 06-19-2012 01:07 AM

    sum preceding nodes in repeating sections

     Hello,
    I'm using Shiraz Cupala's method to repeat table headers of a repeating table across multiple pages - and it works great.

    However, I also want to add a field displaying the amount carried over from the preceeding page. Placing the field at the appropriat position on every page isn't a problem but I can't get the "sum()" expression right.

    My Node-Tree looks like this:

    • MyFields
      • RepSecGroup
        • RepSec
          • PBreak
          • ColumnHead
          • Date
          • Occasion
          • Amount
          • CarryOver Amount
            • Sum

    I want my "carry over"(called "sum") field to sum up the values from all "Amount"-Nodes in the preceding sections and I don't know how to point my sum-command to that node-set.

    My guess was: sum(../preceding-sibling::my:RepSec/my:Amount) with .. going to parent node, then to the preceding sibling nodes of that and from there into the actual node I want within each sibling node. But that isn't working.

    Is there a good source for learning how to "navigate" XPath? MSDN seems to only have an overview of some possible functions to be used in InfoPath expressions

  • 06-25-2012 08:39 AM In reply to

    Re: sum preceding nodes in repeating sections

    What about:

    sum(../../preceding-sibling::my:RepSec/my:Amount)

     

    Hilary Stoupa

  • 06-25-2012 11:53 PM In reply to

    Re: sum preceding nodes in repeating sections

     Yes, that's it! Thank you!

     So all I was missing was another "../"? I spent so many hours trying to figure it out... I thought each dot would move me up one parent node.

     Just in case someone else finds this post with a similar problem:

     I also added a subtotal which includes the amount of the current node. The formular then reads: "sum(../../preceding-sibling::my:RepSec/my:Amount) + sum(../../self::my:RepSec/my:Amount)

  • 06-26-2012 08:18 AM In reply to

    Re: sum preceding nodes in repeating sections

    .. moves you to the parent - here's a W3 Schools page with a bit more explanation.

    Hilary Stoupa

  • 01-30-2024 06:31 AM In reply to

    • stevec
    • Not Ranked
    • Joined on 05-16-2023
    • Posts 2

    Re: sum preceding nodes in repeating sections

    I know this is an older thread but hoping for some assistance. My XML (nodes) look like this - replacing the arrow brackets with round for formatting
      (dsStatement)
      (tt-printdata)
      (EmailSubject)Statement(/EmailSubject)
      (/tt-printdata)
      (StatementHeader)
      (CompanyNo)5000(/CompanyNo)
      (StatementLine)
      (InvoiceCharge)689.0(/InvoiceCharge)
      (InvoiceCredit)0(/InvoiceCredit)
      (/StatementLine)
      (StatementLine)
      (InvoiceCharge)0(/InvoiceCharge)
      (InvoiceCredit)-89.0(/InvoiceCredit)
      (/StatementLine)
      (StatementLine)
      (InvoiceCharge)129.0(/InvoiceCharge)
      (InvoiceCharge)129.0(/InvoiceCharge)
      (InvoiceCredit)0(/InvoiceCredit)
      (/StatementLine)
      (/StatementHeader)
      (/dsStatement)

    My desired output would be an extra column that gives me the running total of the statement.

    Charge Credit Balance

    689.00 0 689.00

    0 -89.00 600.00

    129.00 0 729.00

    I tried the following (don't get any errors) but just calculates as 0.00

    sum(../../../preceding-sibling::dsStatement:StatementLine/dsStatement:InvoiceCharge) + sum(../../../preceding-sibling::dsStatement:StatementLine/dsStatement:InvoiceCredit) I've tried re-creating this with no luck so any help / assistance would be greatly appeciated.
  • 01-30-2024 07:15 AM In reply to

    Re: sum preceding nodes in repeating sections

    I've attached a sample form. Right click the linked form, select save as to save locally. Right click the saved form, select Design to open in design mode, then preview. I used your XML as a secondary data source. I think there may be two issues with your formula - but I don't know how your form is set up. That is, I don't know where the control using your formula is located. You'll see in my form, the balance column is inside the repeating table - so the context is the repeating "StatementLine" node. Yours, since I see "../../../" in it, I'm assuming it is somehow not in the repeating table. I would think for a running table, you need the sum of the preceding rows along with the current row values, like: sum(preceding-sibling::dsStatement:StatementLine/dsStatement:InvoiceCharge) + sum(preceding-sibling::dsStatement:StatementLine/dsStatement:InvoiceCredit + dsStatement:StatementLine/dsStatement:InvoiceCharge + dsStatement:StatementLine/dsStatement:InvoiceCredit
    Hilary Stoupa

  • 01-30-2024 07:56 AM In reply to

    • stevec
    • Not Ranked
    • Joined on 05-16-2023
    • Posts 2

    Re: sum preceding nodes in repeating sections

    Thank you for reply - I will give those a go and let you know if any of them work.
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.