I have an inventory form that has multiple sections in which the same part # can be entered. (Think of each section like a grouping of parts, and parts can be duplicated between sections.) After all the data is entered I want to be able to display one repeating table that has one row for each unique part #. I want this row to have the total quantity for this part # across all sections. So if a user entered part # 125P-4 in three sections, with quantities of 2, 5, and 1, respectively, I want the summary inventory table to show only one row for part 125P-4 with a total qty of 8.
Each part is represented by a repeating group called Item, which has, among other child elements, a PartNum element.
I figured out the XPath expression to filter the repeating table bound to the Item group so that only unique part numbers appear:
PartNum = not(my:PartNum = preceding::my:PartNum)
I've been trying for hours to figure out the XPath to show the total qty for each PartNum. I added another child element called ItemTotalQty to the Item group element. For the default value I'm able to get as far as displaying the total quantity across all sections for a hardcoded PartNum, e.g. the following yields 8 using my above scenario:
sum(/descendant-or-self::node()/my:Item[my:PartNum =
"125P-4"]/my:ItemQty)
But it shows "8" for each row in the repeating table. So what I need to do is swap out the hardcoded part # "125P-4" with the unique PartNum in each row of the filtered repeating table. In other words, I want to say: "gimme the sum of all the Item\ItemQty elements where the Item\PartNum element = each unique PartNum entered by the user into the form." Is this even possible? How would I do this?