# useAverage

*Category:* Utilities
*Section:* Data aggregation hooks
*Source:* https://uikit.developers.rio.cloud/#/utilities/useAverage
*Captured:* 2026-04-27T14:59:45.572Z

Calculates the arithmetic mean of numeric values extracted from a list of objects using a dot-separated path. Supports localized number formats through optional locale configuration.

## useAverage

### Example: Example 1

Average weight deliveries 1: 982,69 kg
Average weight deliveries 2: 982,69 kg

#### React (tsx)

```tsx
import { IntlProvider, FormattedNumber } from 'react-intl';

import useAverage from '@rio-cloud/rio-uikit/useAverage';

const deliveries1 = [
    { shipment: { weight: '1.200,5 kg' } },
    { shipment: { weight: '980,25 kg' } },
    { shipment: { weight: '750 kg' } },
    { shipment: { weight: '1.000 kg' } },
];

const deliveries2 = [
    { shipment: { weight: 1200.5 } },
    { shipment: { weight: 980.25 } },
    { shipment: { weight: 750 } },
    { shipment: { weight: 1_000 } },
];

export default () => {
    const averageWeight1 = useAverage(deliveries1, 'shipment.weight', {
        locale: 'de-DE',
    });

    const averageWeight2 = useAverage(deliveries2, 'shipment.weight');

    return (
        <IntlProvider locale='de-DE'>
            <div>
                Average weight deliveries 1:{' '}
                <b>
                    <FormattedNumber value={averageWeight1} style='unit' unit='kilogram' maximumFractionDigits={2} />
                </b>
            </div>
            <div>
                Average weight deliveries 2:{' '}
                <b>
                    <FormattedNumber value={averageWeight2} style='unit' unit='kilogram' maximumFractionDigits={2} />
                </b>
            </div>
        </IntlProvider>
    );
};
```

#### HTML (html)

```html
<div>Average weight deliveries 1: <b>982,69 kg</b>
</div>
<div>Average weight deliveries 2: <b>982,69 kg</b>
</div>
```

#### Props: Options for the `useAverage` hook

### Options for the `useAverage` hook

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| items | unknown[] | — | The array of objects to extract numeric values from. |
| path | string | — | Dot-separated path to the numeric value inside each object. |
| options | object | — | Optional configuration for number parsing. |
| └locale | string | "en-GB" | Locale string used for parsing localized number formats. Affects grouping and decimal separator interpretation. |

#### Props: Return value of the `useAverage` hook

### Return value of the `useAverage` hook

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| value | number | — | The average of all valid numeric values found at the given path in the item list. |