Is operation "Subtract" supported ?

Aug 21, 2011 at 9:25 AM
Edited Aug 21, 2011 at 9:26 AM

Hi, thanks for the very nice plugin. 

Btw, can you show me how to calculate the "Remaining Work" based on this formula:

Remaining Work = Estimated Work - Completed Work.


I tried to modify the AggregatorItems.xml file, but it doesn't work :

<!--Auto update the remaining work (in hours) based on the completed work vs. the estimated work -->

<AggregatorItem operationType="Numeric" operation="Subtract" linkType="Self" workItemType="Task"> 

                <TargetItem name="Remaining work"/> 

                <SourceItem name="Original Estimate"/> 

                <SourceItem name="Completed work"/>



Is there a way to do subtraction ? Thanks for the help.


Sep 21, 2011 at 6:08 PM

I tried the same thing and it "sums" up the source items as negative.  Is there a way to do this?


Apr 13, 2012 at 7:40 PM
StanTheMan wrote:

I tried the same thing and it "sums" up the source items as negative.  Is there a way to do this?


Here's the workaround I used to make the subtract operation work correctly.

  1. Create a new field in each work item template to hold the negative value of Completed Work.  I added a field called "Custom.TempCompletedWork" to the Task Work Item Type definition.  I do not show it on the work item layout, so it's basically a "hidden" field in our project.
  2. In AggregatorItems.xml, it takes two Aggregator Items to get the correct calculation.  In the first one, I used subtract to put the hours for Work Completed into Custom.TempCompletedWork as a negative number.  The second one is a sum of Estimate and Custom.TempCompletedWork, which results in the correct value for Remaining Work.  If it shows up as a negative number, it now means that the work item took longer to complete than estimated.
    	<!--Use "subtract" to write the value of Completed Work as a negative number to a hidden field.-->
        <AggregatorItem operationType="Numeric" operation="Subtract" linkType="Self" workItemType="Task">
    	  <TargetItem name="TempCompletedWork"/>
    	  <SourceItem name="Completed Work"/>
      <!--Calculate Remaining Work on the task by adding Estimate plus the negative value of Completed Work found in the hidden TempCompletedWork field.-->
      <AggregatorItem operationType="Numeric" operation="Sum" linkType="Self" workItemType="Task">
    		<Condition leftField="Estimate" operator="GreaterThan" rightValue="0"/>
    	  <TargetItem name="Remaining Work"/>
    	  <SourceItem name="TempCompletedWork"/>
    	  <SourceItem name="Estimate"/>
    Oh yeah, I have the condition in there because not all Team Projects in our Team Project Collection have the estimate field.  I should probably put that condition as needed into all of the Aggregator Items, just in case.