Getting Values from Repeating Table - InfoPath Dev
in

InfoPath Dev

Getting Values from Repeating Table

Last post 03-24-2009 10:31 AM by zxkuqyb. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 10-02-2006 07:53 AM

    Getting Values from Repeating Table

    Hi
    I am trying to get the sum of some of the values in a repeating table. I was wondering if this can be done, if so, can anyone tell me how this is done. Thanks,

    Lets say I have a table like this

    Name Score
    John 12
    David 14
    John 15
    John 16
    David 10
    Jane 17

    What I want is

    Name Score
    John 43
    David 24
    Jane 17
  • 10-02-2006 04:19 PM In reply to

    Re: Getting Values from Repeating Table

    Yes, you should be able to do this without adding anything to your schema by employing some rather tricky XPath and view tricks.

    1. Right-click and drag the repeating group into the view as a repeating section.

    This repeating group will be exactly what you have as the input table and it will display all of the rows, but you only want to display unique rows. To do this, add conditional formatting on the repeating section.

    2. Double-click the new repeating section, go to Display tab, and then click Conditional Formatting.
    3. Click the Add button, and add the condition something like this: "not(. = preceding-sibling::my:RepeatingGroup/my:Name)". See this HowTo for a similiar example: http://infopathdev.com/howto/tutorials/default.aspx?i=51dce616335a4ff6a78f2d289baf4651

    Now that you are displaying the first instance of each name, you need to add expression boxes to display the information.

    4. From the Controls task pane insert an expression box into the new repeating section.
    5. From the XPath selection dialog, select the Name node, and then click OK.
    6. Add another expression box, but this time you will use a formula. The formula will be of this form: "sum( ../my:RepeatingGroup[my:Name = current()/my:Name]/my:Total)"

    After this everything should be work. This is pretty straightforward, but getting the XPath expressions correct might take some tweaking. Let us know if you need any more help!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-04-2006 07:41 AM In reply to

    Re: Getting Values from Repeating Table

    Thanks,

    I got it to work.

    But I left out something important in my original question.

    I actually have 3 columns (game number, name, score) and a dropdown box. I was trying to make it so when I choose the game number in the dropdown box, it would show the total score of each person for that game.

    I know this complicates things quite abit, but is it possible??

    so i have a table like this

    Game#, Name, Score
    1 John 12
    1 David 14
    1 John 15
    2 John 16
    1 David 10
    2 Jane 17
    2 David 16
    1 David 12

    so when i choose game 1 i would get
    Name Score
    John 27
    David 24

    and when i choose game 2 i would get
    Name Score
    John 16
    David 16
    Jane 17
  • 10-04-2006 10:49 AM In reply to

    Re: Getting Values from Repeating Table

    This does make things a little more complicated, but I think all you will have to do is adjust the XPath. I gave two XPaths in the previous example, you will need to adjust them to read as follows:

    (BTW - this condition is to HIDE the row of the repeating section)
    not(. = preceding-sibling::my:RepeatingGroup/my:Name) OR not(/my:FORM_ROOT/my:RepeatingGroup[my:GameNum = /my:FORM_ROOT/my:GameDropDown and my:Name = current()/my:Name])

    ---------------------
    sum( ../my:RepeatingGroup[my:Name = current()/my:Name and my:GameNum = /my:FORM_ROOT/my:GameDropDown]/my:Total)


    Note that the change in the first XPath is only necessary if not every person plays every game. I added the filter to only show people that actually played the game that is chosen, but it is assumed that every person plays every game then the original XPath should work.

    I hope this helps, let us know if you need any other help!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 03-24-2009 10:31 AM In reply to

    • zxkuqyb
    • Not Ranked
      Male
    • Joined on 01-14-2009
    • Indianapolis, IN
    • Posts 18

    Re: Getting Values from Repeating Table

    This is good stuff...I have a similar, but different question...thru a slight adjustment to what you've done here, how would I:

    1.  Evaluate a "UserName" Field on a repeating table (User names will vary across the repeating rows)

    2.  Compare it to the "CurrentUser" who is signed in (I get this value from the GetUserProfileByName Web Service)

    3.  Disable a Radio Button on the Repeating Row where the "UserName" on that specific row != the "CurrentUser"

    The examples on this site are awesome and when I modify one of your examples:  not(/my:Fields/my:BMApproval_Section/my:BMDetail_Group/my:BrandManager[. = /my:Fields/my:Misc/my:Current_User])

    it appears as if it doesn't discriminate accross each Repating Row, rather, the entire table.  How would I alter the above statement to evaluate the "BrandManager" against the "CurrentUser" to hide the Radio Button Control if they don't equal each other?

    Many Thanks!!!

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