All Products
Search
Document Center

Resource Orchestration Service:Fn::Avg

Last Updated:Mar 15, 2024

The built-in function Fn::Avg returns the average value of a set of numbers.

Declaration

  • JSON

    {
      "Fn::Avg": [
        ndigits,
        [
          number1,
          number2,
          ...
        ]
      ]
    }
  • YAML

    • Syntax for the full function name:

      Fn::Avg:
        - ndigits
        - - number1
          - number2
          - ...
    • Syntax for the short form:

      !Avg [ndigits, [number1, number2, ...]]

Parameters

  • ndigits: the number of decimal places to display. The value must be an integer.

  • [number1, number2, ...]: the set of elements whose average value you want to calculate. Each element must be a number or a string that can be converted into a number.

Return value

The average value of the set of numbers.

Examples

!Avg [1, [1, 2, 6]]
!Avg [1, [1, 2, 6.0]]

In the preceding examples, 3.0 is returned.

Supported functions