← All pipes
Numbers

sumBy

Sum finite numeric fields for dashboard totals.

Use it in your component

Standalone component
import { Component } from '@angular/core';
import { SumByPipe } from 'extra-pipe';

@Component({
  standalone: true,
  imports: [SumByPipe],
  template: `{{ [{"amount":2},{"amount":4}] | sumBy: "amount" }}`,
})
export class ExampleComponent {

}

Template
{{ [{"amount":2},{"amount":4}] | sumBy: "amount" }}

Try it live.

The output below runs the packed library. Edit data, not code.

Use double quotes for text, or a number, array, object or null.
Ordered parameters: key. Locale is controlled separately.
This pipe has no locale override.
Live template data
readonly value = [
  {
    "amount": 2
  },
  {
    "amount": 4
  }
] as const;
readonly parameter0 = "amount";
{{ value | sumBy: parameter0 }}

Rendered output

6