The following example shows how to build a complex expression where the top level function, **ratioPairs**, operates on two **groupBy** functions nested at the same level.

The **ratioPairs** functions divide pairs of time series. The first **groupBy** expression is the numerator and the second **groupBy** expression is the denominator. Each **groupBy** function must have the same values. The denominator **must** have at least one (1) output metric.

**Note**: The * ratioPairs* and

*functions each use a custom template, which contains the entire tree structure required for completing the function expression.*

**divideSeries****How to create a complex function using** RatioPairs

- From the Navigation Panel, click
**Metric Explorer**. - Click above the expression.
- In the Function dropdown list, select
**ratioPairs****.**The template for the ratioPairs function appears with the necessary expression tree structure:

- In each
**groupBy**function node:- In the
**Aggregation**dropdown list, select the Aggregation type: Avg, Sum, Median, Max, Min, Std - In the
**GroupBy**dropdown list, select the property to group by.

- In the
- In each empty expression node, select property and value pairs, as required.

The Expression Builder now shows both**groupBy**functions within the**ratioPairs**function as completed. - Save the expression (see the relevant saving sections
**here**).