Sum values in repeating table based on drop down selection - InfoPath Dev Sign in | Join | Help in Newbie Questions InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Newbie Questions » Sum values in repeating table based on drop down selection 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: Oldest to newest Newest to oldest Previous Next 01-21-2009 03:16 PM ezfix Joined on 01-21-2009 Posts 4 Sum values in repeating table based on drop down selection Reply Contact 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? Filed under: repeating table, dropdown, calculations, 2003 infopath controls, newbie questions 01-21-2009 03:42 PM In reply to Ted Fitch Joined on 02-27-2006 Posts 567 Re: Sum values in repeating table based on drop down selection sum values sample.xsn Mark as Not AnswerMark as Answer... Reply Contact 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 Joined on 01-21-2009 Posts 4 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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 brjan999 Joined on 10-22-2009 Denver Posts 12 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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/211. $5.002. $10.003. $15.00Meals for 10/221. $8.002. $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 gdgonzal Joined on 01-09-2009 Posts 37 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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 Jimmy Joined on 07-03-2008 Posts 2,595 Re: Sum values in repeating table based on drop down selection sum values sample.xsn Mark as Not AnswerMark as Answer... Reply Contact Here's the same form, saved as an InfoPath 2003 form. Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 03-02-2010 11:30 AM In reply to gdgonzal Joined on 01-09-2009 Posts 37 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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 Joined on 06-24-2015 Tacoma, WA Posts 8 Re: Sum values in repeating table based on drop down selection Externship - Test.xsn Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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 Joined on 06-24-2015 Tacoma, WA Posts 8 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact So - sum(../my:CategorySummary/my:StudentData/my:Count[../my:SectionType != "Needs Improvement"]) div ../my:TotalCountwould 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 Joined on 06-24-2015 Tacoma, WA Posts 8 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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 Joined on 06-24-2015 Tacoma, WA Posts 8 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Sum values in repeating table based on drop down selection Mark as Not AnswerMark as Answer... Reply Contact 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.
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?
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
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!!!
Meals for 10/211. $5.002. $10.003. $15.00
Any help would be appreciated.
Thanks again for your time.
Can you provide an example of this for InforPath 2003? I cannot open the attachment you originally provided, thank you.
Here's the same form, saved as an InfoPath 2003 form.
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
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....
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?
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?
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?