<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Xpath code to filter by department</title><link>https://www.infopathdev.com:443/forums/thread/14902.aspx</link><pubDate>Tue, 21 Nov 2006 17:42:14 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14902</guid><dc:creator>Matt Faus</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14902.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14902</wfw:commentRss><description>You should be able to sum all the entries for one department with XPath, try something more like this:&lt;br /&gt;&lt;br /&gt;sum(xdXDocument:GetDOM("TOSSReceive")/dfs:myFields/dfs:dataFields/d:TOSS[@employeeDepartment = xdXDocument:GetDOM()/my:Root/my:DepartmentDropDown]/@monthlyExpenses)&lt;br /&gt;&lt;br /&gt;You need to compare the @employeeDepartment attribute to the value of the drop-down, but neither of your given XPaths do this.&lt;br /&gt;&lt;br /&gt;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:&lt;br /&gt;&lt;br /&gt;1. Type "sum("&lt;br /&gt;2. Click "Insert field or group"&lt;br /&gt;3. Find the Group that field that you are trying to sum, highlight it&lt;br /&gt;4. Click Filter Data in the lower left corner of the dialog box&lt;br /&gt;5. Insert the condition so that "employeeDepartment" IS EQUAL TO &lt;br /&gt;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.&lt;br /&gt;7. Click OK until you are back on the expression box formula field.&lt;br /&gt;8. type ")" to close the sum function&lt;br /&gt;9. click OK</description></item><item><title>Xpath code to filter by department</title><link>https://www.infopathdev.com:443/forums/thread/12985.aspx</link><pubDate>Tue, 21 Nov 2006 15:58:13 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12985</guid><dc:creator>Michael71</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12985.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12985</wfw:commentRss><description>I,ve been trying to get this Xpath right for 15 days now. I just want to add up monthly Expenses for the current year from a database for the department selected drop down box. Is this Xpath good enough or do I need to add rules as well. Because I've tried all kinds of Xpath and it won't work.&lt;br /&gt;&lt;br /&gt;sum(xdXDocument:GetDOM("TOSSReceive")/dfs:myFields/dfs:dataFields/d:TOSS[@employeeDepartment = /../dfs:dataFields/d:TOSS/@employeeDepartment]/@monthlyExpenses)&lt;br /&gt;&lt;br /&gt;&lt;font size="5"&gt;&lt;b&gt;This works for one Department&lt;/b&gt;&lt;/font id="size5"&gt; &lt;br /&gt;&lt;br /&gt;sum(xdXDocument:GetDOM("TOSSReceive")/dfs:myFields/dfs:dataFields/d:TOSS[@employeeDepartment = "5201 - Management IS-Hatfield"]/@monthlyExpenses)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;here is my Shema&lt;br /&gt;&lt;br /&gt;- &amp;lt;dfs:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-10-03T15:05:30" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"&amp;gt;&lt;br /&gt;- &amp;lt;dfs:queryFields&amp;gt;&lt;br /&gt;&amp;lt;q:TOSS ReportID="" expenseReportDate="" expenseStartDate="" expenseEndDate="" monthlyExpenses="" monthlyBudgeted="" monthlyBudgetVariance="" expenseExplain="" CapitalReportDate="" CapitalStartDate="" CapitalEndDate="" monthlyCapitalExpenses="" monthlyCapitalBudgeted="" monthlyCapitalVariance="" CapitalExplain="" employeeDepartment="" /&amp;gt; &lt;br /&gt;&amp;lt;/dfs:queryFields&amp;gt;&lt;br /&gt;- &amp;lt;dfs:dataFields&amp;gt;&lt;br /&gt;&amp;lt;d:TOSS ReportID="" expenseReportDate="" expenseStartDate="" expenseEndDate="" monthlyExpenses="" monthlyBudgeted="" monthlyBudgetVariance="" expenseExplain="" CapitalReportDate="" CapitalStartDate="" CapitalEndDate="" monthlyCapitalExpenses="" monthlyCapitalBudgeted="" monthlyCapitalVariance="" CapitalExplain="" employeeDepartment="" /&amp;gt; &lt;br /&gt;&amp;lt;/dfs:dataFields&amp;gt;&lt;br /&gt;- &amp;lt;my:YTDTotals&amp;gt;&lt;br /&gt;&amp;lt;my:ytdExpenses /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdBudgeted /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdVariance /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdCapitalExpenses /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdCapitalBudgeted /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdCapitalVariance /&amp;gt; &lt;br /&gt;&amp;lt;/my:YTDTotals&amp;gt;&lt;br /&gt;- &amp;lt;my:YTDTotals&amp;gt;&lt;br /&gt;&amp;lt;my:ytdExpenses /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdBudgeted /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdVariance /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdCapitalExpenses /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdCapitalBudgeted /&amp;gt; &lt;br /&gt;&amp;lt;my:ytdCapitalVariance /&amp;gt; &lt;br /&gt;&amp;lt;/my:YTDTotals&amp;gt;&lt;br /&gt;- &amp;lt;xd:SchemaInfo LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"&amp;gt;&lt;br /&gt;- &amp;lt;xd:Namespaces&amp;gt;&lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;/xd:Namespaces&amp;gt;&lt;br /&gt;&amp;lt;/xd:SchemaInfo&amp;gt;&lt;br /&gt;- &amp;lt;xd:DataConnection Name="TOSSReceive"&amp;gt;&lt;br /&gt;- &amp;lt;dfs:myFields xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-10-03T15:05:30" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"&amp;gt;&lt;br /&gt;- &amp;lt;dfs:dataFields&amp;gt;&lt;br /&gt;&amp;lt;d:TOSS ReportID="" expenseReportDate="" expenseStartDate="" expenseEndDate="" monthlyExpenses="" monthlyBudgeted="" monthlyBudgetVariance="" expenseExplain="" CapitalReportDate="" CapitalStartDate="" CapitalEndDate="" monthlyCapitalExpenses="" monthlyCapitalBudgeted="" monthlyCapitalVariance="" CapitalExplain="" employeeDepartment="" /&amp;gt; &lt;br /&gt;&amp;lt;/dfs:dataFields&amp;gt;&lt;br /&gt;- &amp;lt;xd:SchemaInfo LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"&amp;gt;&lt;br /&gt;- &amp;lt;xd:Namespaces&amp;gt;&lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" /&amp;gt; &lt;br /&gt;&amp;lt;/xd:Namespaces&amp;gt;&lt;br /&gt;&amp;lt;/xd:SchemaInfo&amp;gt;&lt;br /&gt;&amp;lt;/dfs:myFields&amp;gt;&lt;br /&gt;&amp;lt;/xd:DataConnection&amp;gt;&lt;br /&gt;&amp;lt;/dfs:myFields&amp;gt;</description></item></channel></rss>