title: What is the best way to calculate the sum of values in complex table?
body: <p>I have folowing table:</p>
  
  <pre><code>&lt;ng-container *ngFor='let data1 of sectionList'&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  {{data1.name}}
                  &lt;button (click)="ArrRow($event)" style="float: right" id="{{data1.id}}"&gt;+&lt;/button&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr *ngFor="let data2 of (model.Register10Data | filter:'sectionGroup':data1.id); let dataIndex = index"&gt;
              &lt;td&gt;
                  {{data2.SomeNumericValue}}
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Here I need to summing of the data2.SomeNumericValue&lt;/td&gt;&lt;/tr&gt;
      &lt;/ng-container&gt;
  </code></pre>
  
  <p>In this table I'm using @pipe for grouping data. Pipe looks like:</p>
  
  <pre><code>@Pipe({
      name: 'sectionGroup'
  })
  
  export class FilterPipe implements PipeTransform {
      transform(items: any[], field: number, value: number): any[] {
          if (!items) return [];
          return items.filter(it =&gt; (+it[field]) === (+value));
      }
  }
  </code></pre>
  
  <p>This works fine.</p>
  
  <p>I need get summation of <code>data2.SomeNumericValue</code> that's rendering within  *ngFor with pipe. But summation must be rendered outside *ngFor. Above in the example I wrote where it should be.
  Real table contains many columns and rows. And rows can be added dynamically. By some columns i want get summation. I know how to write function and render  result in cell. But I think that summation must calculated inside *ngFor because it is reduce count of iterations. But maybe i'm wrong. How to do this and which method is the best?  </p>