Sum values in repeating table based on drop down selection - InfoPath Dev
in

InfoPath Dev

Sum values in repeating table based on drop down selection

Last post 02-17-2016 07:11 AM by Eric Dumas. 18 replies.
Page 1 of 2 (19 items) 1 2 Next >
Sort Posts: Previous Next
  • 01-21-2009 03:16 PM

    • ezfix
    • Not Ranked
    • Joined on 01-21-2009
    • Posts 4

    Sum values in repeating table based on drop down selection

    I have a simple repeating table with two fields.  The first is a drop down list with status selections of "New", "Pending", "Approved", and "Rejected".  The second is a text field where users enter a dollar value.  I want to sum the dollar amounts in the footer of the repeating table for text fields only in rows where the user has selected "Approved" from the drop down field.  What is the best way to do this so when the drop down value is changed, the sum updates?

  • 01-21-2009 03:42 PM In reply to

    Re: Sum values in repeating table based on drop down selection

    Hi and welcome to the InfoPathDev forums.

    What you want to do to enable this is to add a field outside of your repeating section that is a "sum" field of the dollar value field filtered by the condition that status = approved.  You do this through the function ("fx") for the default value for the "sum" or totals field.

    I have made a simple sample of this for you that you can see in the attached xsn.  When you open this XSN in design mode you can see how this is all working.  This is in InfoPath 2007 format, let me know if you need InfoPath 2003

    Hope this helps

    Ted

  • 01-21-2009 04:40 PM In reply to

    • ezfix
    • Not Ranked
    • Joined on 01-21-2009
    • Posts 4

    Re: Sum values in repeating table based on drop down selection

    Hi,

     Thanks so much for the quick response and sending the sample!  I never saw that "Filter data..." button when selecting the field or group until I worked through your example.

     Works great.  Awesome!  THANKS!!!

  • 10-22-2009 10:19 AM In reply to

    Re: Sum values in repeating table based on drop down selection

    Hi,I thought this was similar to the post that you had helped, so I thought you might be able to help.  I am trying to sum (dollar amount) by date and category that it's in.  For example, let's say I have three categories of expenses: meals, gas, office supplies, and I want to sum a total for each of these items by date.  Let's say I have a (3) meal expenses on 10/21, (2) meal expenses on 10/22, (1) gas expense on 10/21, (3) office supplies purchase on 10/21, and (2) office supplies on 10/22.  All I am concerned about is meals, so what I want to do is a sum formula that looks only at the meals category and sums the total dollar amount by date.  Something like this: 

    Meals for 10/21
    1. $5.00
    2. $10.00
    3. $15.00

    Meals for 10/22
    1. $8.00
    2. $10.00              
     Date                          Expense                     Amount
                                10/21                         Meals                           $30.00
                                10/22                         Meals                           $18.00
     

    Any help would be appreciated. 

    Thanks again for your time.

    Bryan
  • 03-02-2010 09:17 AM In reply to

    Re: Sum values in repeating table based on drop down selection

    Can you provide an example of this for InforPath 2003?  I cannot open the attachment you originally provided, thank you.

  • 03-02-2010 09:24 AM In reply to

    Re: Sum values in repeating table based on drop down selection

     Here's the same form, saved as an InfoPath 2003 form.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-02-2010 11:30 AM In reply to

    Re: Sum values in repeating table based on drop down selection

    Thanks Jimmy...I was wondering if you could help me with this.  I have a filter being applied using a date range (see link below) and I want to sum a total within the context of the defined date range parameter.  Any idea how to incoporate this in to what I already have below?

     

    http://enterprise-solutions.ikreate.nl/infopath2003/filter-repeating-table-date-range-rules.htm

  • 06-24-2015 01:06 PM In reply to

    • autodafey
    • Not Ranked
      Male
    • Joined on 06-24-2015
    • Tacoma, WA
    • Posts 8

    Re: Sum values in repeating table based on drop down selection

    I'm trying to do the same kind of thing and I tried the code exactly as you posted it here. Downloaded your example and I still get an error that the selection field is not recognized. What I want to do is sum only those values that are "Outstanding", "Good", and "Fair" excluding those that are poor to calculate a percentage score in the middle repeating table and place it in the footer next to the total. Basically, the score is a percentage of each of those three only divided by the total number. Since "Needs Improvement" is the only one that I don't want, I planned to use 1-((sum(Count[SectionType="Needs Improvement"])/TotalCount) But, even when I just isolate the formula to sum(Count[SectionType="Needs Improvement"]) Just to see if it will sum the selection only, I can't seem to get it to work. It keeps saying ../my:CategorySummary/my:StudentData/my:CategorySummary/my:StudentData/my:SectionType" does not point to a valid location path of a field or group. Even when I select each field and each function from the button, rather than typing it manually.
  • 06-24-2015 02:09 PM In reply to

    Re: Sum values in repeating table based on drop down selection

     This is in a default in the TotalPerc field, is that right? This XPath validates for me as a default in TotalPerc (XPath will be different if the formula is used someplace else):

    sum(../my:CategorySummary/my:StudentData/my:Count[../my:SectionType != "Needs Improvement"])

    Uh, that's a sum of the count field where the section type is not equal to Needs Improvement - I had trouble understanding what you were wanting to sum.... 

    Hilary Stoupa

  • 06-24-2015 04:40 PM In reply to

    • autodafey
    • Not Ranked
      Male
    • Joined on 06-24-2015
    • Tacoma, WA
    • Posts 8

    Re: Sum values in repeating table based on drop down selection

    That works to give me the Needs Improvement. It's great. So, now I need to divide that by TotalCount to get the percentage. Maybe I just don't understand how this naming works.
  • 06-24-2015 04:56 PM In reply to

    Re: Sum values in repeating table based on drop down selection

     So - sum(../my:CategorySummary/my:StudentData/my:Count[../my:SectionType != "Needs Improvement"]) div ../my:TotalCount

    would be the sum of the count without Needs Improvement divided by Total Count? 

    Hilary Stoupa

  • 06-25-2015 10:24 AM In reply to

    • autodafey
    • Not Ranked
      Male
    • Joined on 06-24-2015
    • Tacoma, WA
    • Posts 8

    Re: Sum values in repeating table based on drop down selection

    It's so weird. Yours works perfectly, but I kept getting errors when I tried to build the formula myself.
  • 06-25-2015 10:51 AM In reply to

    Re: Sum values in repeating table based on drop down selection

     What kind of errors? What are the steps you are taking when you try to build it yourself? What is the full XPath (check the Edit XPath button) of the expression you end up with when you build it yourself?

    Hilary Stoupa

  • 06-25-2015 11:44 AM In reply to

    • autodafey
    • Not Ranked
      Male
    • Joined on 06-24-2015
    • Tacoma, WA
    • Posts 8

    Re: Sum values in repeating table based on drop down selection

    When I build it myself, I am using the buttons on the fx window to make sure that I am selecting the fields (without the xpath checked). I didn't want to inadvertently type something wrong in the syntax. When I do this without the [] attributes, it seems to work fine, but it doesn't handle the [] very well if I type it out. I'm not sure why. It tells me that the path is wrong. I literally typed it as sum(Count[SectionType != "Needs Improvement"]) / TotalCount and made sure that the fields underlined. That's what caused the error above.
  • 06-25-2015 11:51 AM In reply to

    Re: Sum values in repeating table based on drop down selection

     Do you select Count, then select the Filter data button, then select Section Type, then the Is Equal To option, then type in the text Needs Improvement?

    Hilary Stoupa

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