# How to Calculate An Average Value

A lot of companies use averages in commission calculations. For example, it is common to see companies commission reps on the average Annual Contract Value of a contract rather than just the first month's value or the total value.

## Calculating an Average Recipe Steps

Let's tackle this in three steps:

1. Find or calculate the total value you want to average
2. Find or calculate the total duration over which you want to average the total value
3. Divide the total value by the duration

## 1. Find Or Calculate the Total Value

The first step in finding an average value is to find or calculate a total value.  Let's assume you want to find Average Contract Value.  The first step is to find a Total Contract Value.  This is typically a field on the CRM.

To do this, we can create a Variable called TotalContractValue in Spiff and put the following into the Variable's formula:

``deal.Total_Contract_Value__c``

## 2. Find or Calculate the Total Duration

This step can be a bit more complicated.  But typically you are trying to find the length of a deal's contract.  Sometimes you will be lucky and the CRM will already include a calculated field for the total contract duration of the deal's contract.  In this case, you would simply create a variable called something like TotalContractDuration with the following as the formula:

``deal.TotalContractDuration__c``

In other cases, you may need to calculate the contract duration yourself.  Spiff provides a number of tools to help you do this.  Let's assume we have a Contract Start Date and a Contract End Date and we are trying to find the average monthly value of the contract.

To do this, we will make use of Spiff's handy months_to function.  You can define TotalContractDuration in this case as:

``months_to(deal.Contract_Start_Date__c, deal.Contract_End_Date__c)``

This will return the total duration of the contract in months.

## 3.  Divide the Total Value by the Total Duration

The last step is very easy.  We will simply create a new variable called AverageContractACV with this formula:

``deal.TotalContractValue / deal.TotalContractDuration`` 