Sum of repeating table field - InfoPath Dev
in

InfoPath Dev

Sum of repeating table field

Last post 03-27-2012 02:13 PM by AzuDaioh. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 03-26-2012 04:18 PM

    Sum of repeating table field

    I have a repeating table with the following fields:

    • WBA
    • StartDate
    • EndDate
    • DateDiff
    • OPAmount

    And a repeating table footer with the following field:

    • TotalOP

    To calculate the DateDiff, I followed the steps here: http://alecpojidaev.wordpress.com/2008/12/30/infopath-codeless-programming-walkthrough-2/
    The finalize rule is set on [DateDiff] field.

    To calculate the OP Amount, I modified the 'finalize' rule adding the following action:

    • 2nd action
      • Action: Set a Field Value
      • Field: OPAmount
      • Value: WBA / 7 * DateDiff

    Now, I would like to sum the [OPAmount] column so I set the default value of [TotalOP] = sum(OPAmount).  However, I got an error message about 'exceeding the maximum limit' so upon further research, I need to modifiy the 'finalize' rule to calculate my [TotalOP] field so I added:

    • 3rd Action
      • Action: Set a Field Value
      • Field: TotalOP
      • Value: sum(OPAmount)

    The third action in the finalize rule does not sum up the [OPAmount] column. It only displays the OPAmount value on the *last* row.  Is there a way to calculate the [TotalOP] each time a row is added?  I also posted a question on Alec's site.  But, I'm hoping I can get someone else to enlighten me about repeating tables and rules. 

     Thank you,

     

  • 03-26-2012 04:51 PM In reply to

    Re: Sum of repeating table field

    I always seem to find the answers right after I post the question. Sorry, please disregard my previous post. After many attempts to use preceding-sibling, I finally got the correct syntax. :)

    This is the value I used for the 3rd action:
    sum(../preceding-sibling::*/my:OPAmount) + ../my:OPAmount

  • 03-26-2012 05:03 PM In reply to

    Re: Sum of repeating table field

    Sometimes it seems the act of asking the question helps us find the answer on our own... Thanks for updating with your resolution.

    Hilary Stoupa

  • 03-27-2012 10:50 AM In reply to

    Re: Sum of repeating table field

    I am still confused about preceding-sibling.  I think I understand the use of it in repeating table but when I try to apply it to repeating section, it doesnt work.

     Here is structure of my fields:

    myFields
    POPCalculator
    group1
    group2
    group3
    | group4
    | Bgn_Date
    | End_Date
    | DateDiff
    | OPAmount
    WBA
    TotalOP
            

     

    Group4 is my repeating table.  Group3 contains the footer and header for the repeating table. Group2 is the repeating section. Group1 contains the field 'GrandTotal' where I want to display the sum(TotalOP)
    I made various attempts to use the preceding-sibling for my repeating section but all failed. I googled but I can't find anything that would work, or maybe I just didnt understand much about preceding-sibling.

    Here's my last attempt: sum(../preceding-sibling::my:group3/../my:POP_TotalOP)

     Any help is greatly appreciated.  Thanks,

  • 03-27-2012 02:06 PM In reply to

    Re: Sum of repeating table field

    Well, just to be annoyingly specific, a repeating table and a repeating section are just controls - the underlying data structure (which is a repeating group) is the same. Now, if you want to sum a field like TotalOP, you can put an expression box inside a section bound to group1 and use the formula sum(POP_TotalOP), selecting the field using the field picker - that will just sum all POP_TotalOP nodes that are a child of group1. If you have a field you want this value in, you'd use the same formula - just sum the nodes, no need for preceding sibling.

    Hilary Stoupa

  • 03-27-2012 02:13 PM In reply to

    Re: Sum of repeating table field

    Hi Hilary,


    Thanks for the reply.  I already tried it, but it give me an error message regarding 'exceeding the maximum limit' -- which I think is related to the Date Difference calculations I followed from the link on my first post.  So, I'm trying to find another way to do the calculations via rule as suggested from the same site.  Thanks again.

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