← All pipes
Numbers

summarizeBy

One-pass count/sum/mean/min/max summary.

Use it in your component

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

@Component({
  standalone: true,
  imports: [SummarizeByPipe, JsonPipe],
  template: `{{ [{"amount":2},{"amount":4}] | summarizeBy: "amount" | json }}`,
})
export class ExampleComponent {

}

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

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 | summarizeBy: parameter0 | json }}

Rendered output

{
  "count": 2,
  "sum": 6,
  "mean": 3,
  "min": 2,
  "max": 4
}