← All pipes
Numbers

averageBy

Mean numeric fields for dashboard summaries.

Use it in your component

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

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

}

Template
{{ [{"amount":2},{"amount":4}] | averageBy: "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 | averageBy: parameter0 }}

Rendered output

3