You should be able to sum all the entries for one department with XPath, try something more like this:
sum(xdXDocument:GetDOM("TOSSReceive")/dfs:myFields/dfs:dataFields/d:TOSS[@employeeDepartment = xdXDocument:GetDOM()/my:Root/my:DepartmentDropDown]/@monthlyExpenses)
You need to compare the @employeeDepartment attribute to the value of the drop-down, but neither of your given XPaths do this.
You should be able to do all of this from the designer and the only bit you'll have to type in manually is the sum() function call. So in the Expression box, follow these steps:
1. Type "sum("
2. Click "Insert field or group"
3. Find the Group that field that you are trying to sum, highlight it
4. Click Filter Data in the lower left corner of the dialog box
5. Insert the condition so that "employeeDepartment" IS EQUAL TO
6. In the last drop-down box select "Select Field or Group" - browse to whatever node that the drop-down is bound to, select, click OK twice.
7. Click OK until you are back on the expression box formula field.
8. type ")" to close the sum function
9. click OK
Matt Faus / Microsoft InfoPath MVPQdabra® Software / Streamline data gathering to turn process into knowledge