title: How to sum multiple items in an object in PowerShell?
body: <p>I have:</p>
  
  <pre><code>$report.gettype().name
  Object[]
  
  echo $report
  
  Item                       Average
  --                         -------
  orange                     0.294117647058824
  orange                    -0.901960784313726
  orange                    -0.901960784313726
  grape                      9.91335740072202
  grape                      0
  pear                       3.48736462093863
  pear                      -0.0324909747292419
  pear                      -0.0324909747292419
  apple                     12.1261261261261
  apple                     -0.0045045045045045
  </code></pre>
  
  <p>I want to create a variable, $total, (such as a hash table) which contains the sum of the 'Average' column for each item, for example,</p>
  
  <pre><code>echo $total
  
  orange  -1.5097
  grape    9.913
  pear     3.423
  apple   12.116
  </code></pre>
  
  <p>Right now I'm thinking of looping through the $report, but it's hell ugly, and I am looking for something more elegant than the following starting point (incomplete):</p>
  
  <pre><code>$tmpPrev = ""
  foreach($r in $report){
      $tmp = $r.item
      $subtotal = 0
      if($tmp &lt;&gt; $tmpPrev){
          $subtotal += $r.average
      }
  </code></pre>
  
  <p>How could I do this?</p>