avg Function | Vantage CX - 1.4 - avg - Vantage Customer Experience

Vantage Customer Experience User Guide

Product
Vantage Customer Experience
Release Number
1.4
Release Date
June 2021
Content Type
User Guide
Publication ID
B035-3800-099K
Language
English (United States)

Returns the average of a set of values.

The following example finds the values of all price attributes in the complex attribute category named cart, adds the prices, divides the sum by the number of prices, and returns the average. The rest of the formula then takes that average and returns true if the average is greater than 1.

avg(
    get("Account.cart"),
     "price"
) > 1

By default, the avg function accesses the most current data. The Session modifier enables the avg function to access the session data, which is all of the data in the active session. For example, the Session modifier accesses not only the current value for an attribute but all the previous values for that attribute in the session. Use the Session modifier to use a simple attribute rather than a complex attribute with the avg function.