Average transaction value (ATV) helps a dashboard show how much revenue, on average, each transaction generated. Users can compare it across products, categories, customer groups, states, and time. section 6.1.2
Calculate ATV by dividing total sales by the total number of transactions in the selected slice: total sales / sum of transactions. A transaction represents one purchase, regardless of how many items it contains. section 6.4.1
Three-row calculation
Suppose three rows contain sales of $500, $300, and $200, with 10, 5, and 8 transactions. Total sales equal $1,000, and total transactions equal 23, so ATV is $1,000 / 23 = $43.48. section 6.4.1
Use ATV carefully when building dashboard views:
- Recalculate the ratio for each filtered group by dividing that group’s total sales by its transaction count. section 6.5.2
- Treat ATV as a ratio rather than a component of a pie chart, because dimension-wise ATV values do not add up to 100 percent. section 6.5.2
- Configure ATV as a dollar-valued metric and guard the calculation against a zero-sales denominator. section 6.4.2
Listing 6.7 Configuring metrics
from metric import Metric
def margin_percent(df):
total_sales = df["Sales"].sum()
return df["Gross margin"].sum() / total_sales if total_sales > 0 else 0
def average_transaction_value(df):
total_sales = df["Sales"].sum()
return total_sales / df["Transactions"].sum() if total_sales > 0 else 0
metrics = {
"Total sales": Metric(
title="Total sales",
func=lambda df: df["Sales"].sum(),
type="dollars"
),
"Gross margin": Metric(
title="Gross margin",
func=lambda df: df["Gross margin"].sum(),
type="dollars"
),
"Margin %": Metric(
title="Margin %",
func=margin_percent,
type="percent"
),
"ATV": Metric(
title="Average transaction value",
func=average_transaction_value,
type="dollars"
)
}
display_metrics = ["Total sales", "Gross margin", "Margin %", "ATV"]
A compact Python configuration shows ATV as a reusable dollar metric alongside total sales, gross margin, and margin percentage. section 6.4.2

