Commission disputes are one of the biggest sources of friction between sales and finance. Reps want to know what they will earn before a deal closes. Finance wants reps to stop asking. A lightweight Streamlit app that lets reps calculate their own estimated commissions solves both problems.
Defining the Commission Plan¶
Most commission plans have a base rate with accelerators above quota. Define the plan as a Python dictionary:
COMMISSION_PLAN = {
"base_rate": 0.10, # 10% on deals up to quota
"accelerator_1": {
"threshold": 1.0, # 100-125% of quota
"cap": 1.25,
"rate": 0.15, # 15% accelerator
},
"accelerator_2": {
"threshold": 1.25, # 125%+ of quota
"cap": float("inf"),
"rate": 0.20, # 20% super-accelerator
},
"quarterly_quota": 250000,
}
The Commission Calculation Engine¶
The calculator applies tiered rates based on where the rep stands against quota:
def calculate_commission(deals, quota, plan):
total_bookings = sum(deals)
attainment = total_bookings / quota if quota > 0 else 0
commission = 0.0
breakdown = []
# Base commission on bookings up to quota
base_eligible = min(total_bookings, quota)
base_comm = base_eligible * plan["base_rate"]
commission += base_comm
breakdown.append(("Base (up to quota)", base_eligible, plan["base_rate"], base_comm))
# Accelerator 1
if total_bookings > quota:
tier1_cap = quota * plan["accelerator_1"]["cap"]
tier1_eligible = min(total_bookings, tier1_cap) - quota
tier1_comm = tier1_eligible * plan["accelerator_1"]["rate"]
commission += tier1_comm
breakdown.append(("Accelerator 1", tier1_eligible, plan["accelerator_1"]["rate"], tier1_comm))
# Accelerator 2
tier1_cap = quota * plan["accelerator_1"]["cap"]
if total_bookings > tier1_cap:
tier2_eligible = total_bookings - tier1_cap
tier2_comm = tier2_eligible * plan["accelerator_2"]["rate"]
commission += tier2_comm
breakdown.append(("Accelerator 2", tier2_eligible, plan["accelerator_2"]["rate"], tier2_comm))
return commission, attainment, breakdown
Building the Streamlit Interface¶
The app gives reps a simple form to enter their deals and see commissions instantly:
import streamlit as st
st.set_page_config(page_title="Commission Calculator", page_icon="$")
st.title("Commission Calculator")
st.markdown("Enter your deals to see your estimated commission payout.")
quota = st.number_input(
"Your Quarterly Quota ($)",
value=COMMISSION_PLAN["quarterly_quota"],
step=10000,
)
st.subheader("Enter Your Deals")
num_deals = st.slider("Number of deals", 1, 20, 3)
deals = []
cols = st.columns(3)
for i in range(num_deals):
with cols[i % 3]:
amount = st.number_input(
f"Deal {i + 1} ($)", min_value=0, value=25000, step=5000, key=f"deal_{i}"
)
deals.append(amount)
Displaying Results¶
Show the commission breakdown with clear formatting:
if st.button("Calculate Commission"):
commission, attainment, breakdown = calculate_commission(
deals, quota, COMMISSION_PLAN
)
col1, col2, col3 = st.columns(3)
col1.metric("Total Bookings", f"${sum(deals):,.0f}")
col2.metric("Quota Attainment", f"{attainment:.0%}")
col3.metric("Estimated Commission", f"${commission:,.0f}")
st.subheader("Commission Breakdown")
import pandas as pd
df = pd.DataFrame(breakdown, columns=["Tier", "Eligible Amount", "Rate", "Commission"])
df["Eligible Amount"] = df["Eligible Amount"].apply(lambda x: f"${x:,.0f}")
df["Rate"] = df["Rate"].apply(lambda x: f"{x:.0%}")
df["Commission"] = df["Commission"].apply(lambda x: f"${x:,.0f}")
st.table(df)
if attainment >= 1.25:
st.success("You are in super-accelerator territory!")
elif attainment >= 1.0:
st.info("You have hit quota. Accelerators are active.")
else:
gap = quota - sum(deals)
st.warning(f"${gap:,.0f} to go before you hit quota.")
Running the App¶
Launch the calculator with:
streamlit run commission_calculator.py
Share the URL with your sales team. On Streamlit Community Cloud, you can deploy it for free so reps can access it from anywhere without installing Python.
Key Takeaways¶
- A Streamlit commission calculator eliminates back-and-forth between reps and finance about expected payouts
- Defining the comp plan as a configuration dictionary makes it easy to update rates each quarter without rewriting code
- Visual feedback like progress bars and tiered breakdowns help reps understand exactly how accelerators work
- Labeling output as “estimated” avoids disputes while still giving reps the transparency they want