I'm using a Form Library with InfoPath, and I want to calculate the total Hours by Type, similar to SQL's SUM() GROUP BY. This application will be used to track the learning hours for students over a 4-year period to total how many hours they've accumulated toward a Type of skill (A1, A2, ...).
<my:WrkExprFields>
<my:EmployeeName>Fife Barney</my:EmployeeName>
<my:MonthlyExperience>
<my:PeriodEndDate>2019-01-31</my:PeriodEndDate>
<my:Tasks>
<my:Type>A1</my:Type>
<my:Hours>80</my:Hours>
</my:Tasks>
<my:Tasks>
<my:Type>A2</my:Type>
<my:Hours>4</my:Hours>
</my:Tasks>
<my:Tasks>
<my:Type>A3</my:Type>
<my:Hours>10</my:Hours>
</my:Tasks>
<my:Tasks>
<my:Type>A4</my:Type>
<my:Hours>12</my:Hours>
</my:Tasks>
<my:Tasks>
<my:Type>Holiday</my:Type>
<my:Hours>8</my:Hours>
</my:Tasks>
</my:MonthlyExperience>
<my:MonthlyExperience>
<my:PeriodEndDate>2019-02-28</my:PeriodEndDate>
<my:Tasks>
<my:Type>A2</my:Type>
<my:Hours>80</my:Hours>
</my:Tasks>
<my:Tasks>
<my:Type>A5</my:Type>
<my:Hours>16</my:Hours>
</my:Tasks>
<my:Tasks>
<my:Type>A4</my:Type>
<my:Hours>4</my:Hours>
</my:Tasks>
<my:Tasks>
<my:Type>Vacation</my:Type>
<my:Hours>40</my:Hours>
</my:Tasks>
</my:MonthlyExperience>
</my:WrkExprFields>
I'd like to have an InfoPath view totaling the hours by Type.
Type Hours
==== =====
A1 80
A2 84
A3 10
A4 16
A5 16
Holiday 8
Vacation 40
I was able to successfully create a table with Text Boxes which had Default Values something like:sum(my:MonthlyExperience/my:Tasks[my:Type = "A1"]/my:Hours).
The problem I'm having is that the user specified that the Type field could have any combination of letter and number (many combinations), so I'm hoping for a solution that is more dynamic like a SQL with SUM() and GROUP BY. I was hoping to use an XPath like: concat(distinct-values(/my:MonthlyExperience/my:Tasks/my:Type),' ',sum(my:MonthlyExperience/my:Tasks/my:Hours)), but InfoPath doesn't support the distinct-values function.