Use case

How to Analyze Customer Profitability Using AI

Compare finance-approved customer revenue with direct and allocated service costs, then review contribution profit by account and segment in a governed Cube deployment.

  • Define revenue and cost rules before comparing accounts
  • Compare contribution profit by customer and segment
  • Trace findings to a period, metric, and allocation basis

What is customer profitability analysis with AI?

Customer profitability analysis estimates the contribution profit attributable to each account over a defined period. Start with revenue that follows the finance-approved recognition and adjustment policy, subtract direct service costs and any shared costs assigned under an approved allocation rule, then compare results by account and segment. This is contribution profit, not net income or a universal measure.

Cube is the semantic layer for AI. An agent can query and summarize historical measures when the model defines them and the caller has permission to access them. The workflow helps finance and data teams review account economics; it does not choose an allocation policy, turn missing costs into zero, predict future profitability, or prove why a result changed.

Agree on the revenue and cost basis

Confirm the accounting period, customer grain, currency, and cost allocation rule before comparing accounts. These fictional figures use Q3 2026 and match the worked example below.

Illustrative inputs for a fictional Q3 2026 customer profitability review
MetricIllustrative example
Net recognized revenueQ3 total: $214,000 after the approved discounts, credits, and refunds.
Direct and allocated service costsQ3 total: $104,000, using direct costs plus only finance-approved allocations.
Customer grain and segment22 distinct accounts: 10 Starter, 8 Growth, and 4 Enterprise.
Segment contribution profitStarter: $30,000 net revenue − $18,000 costs = $12,000.
Overall contribution margin$110,000 contribution profit ÷ $214,000 net revenue = 51.4%.
The Prompt

Copy. Paste. Review customer profitability.

Connect to Cube through MCP or the CLI, then run this read-only prompt in your preferred agent.

Start with a Cube deployment connected to your data and a model containing the metrics you want to analyze.

01Connect over MCP

Connect over MCP

Connect your agent to your existing Cube deployment and sign in through OAuth.

MCP endpoint
https://cubecloud.dev/mcp
Sign in to Cube

Complete OAuth in your agent to connect your Cube account.

Choose a deployment

Use your default deployment or select another one available to your account.

Read the MCP setup docs
01Connect with CLI

Connect with CLI

Install the Cube CLI and sign in from a terminal-capable agent.

Install the CLI
curl -fsSL https://raw.githubusercontent.com/cube-js/cube/master/install-cli.sh | sh
Log in (replace TENANT with your account name)
cube login --url https://TENANT.cubecloud.dev
Inspect API operations
cube spec --json
Read the CLI docs

02Run this prompt in your agent

Choose your agent and copy the prompt below.

Prompt for Codex
Connect the Cube MCP server in Codex and select the intended deployment. Use only read-only analytics tools and honor the caller's permissions. Review historical customer profitability using the connected Cube deployment.Use read-only requests. Do not return customer names, emails, or raw identifiers. DEFINITIONS1. Inspect the model for finance-approved net recognized revenue, direct costs,   allocated service costs, account grain, segment dimensions, currency, and   date fields. State each available definition and its owner or source when   exposed by the model.2. Define contribution profit as approved net revenue minus approved direct   service costs minus approved allocated service costs. Define contribution   margin as total contribution profit divided by total net revenue. Follow   the finance-approved treatment of discounts, credits, refunds, taxes,   foreign exchange, and revenue recognition; do not invent a policy.3. Count each account once using its stable customer key. For segment   comparisons, use segment membership at the period start; for new accounts,   use their first recorded segment in the period. Keep unassigned accounts   visible as Unknown.4. Do not treat absent cost records as zero. Separate confirmed zero costs   from missing or incomplete cost coverage. Do not rank an account as   profitable if its required cost inputs are incomplete. ANALYSIS1. Review the last complete calendar quarter available in the deployment.   State its exact inclusive start and end dates, timezone, and currency.   Compare it with the immediately preceding complete quarter of equal length   using the same definitions and filters. If either period is unavailable,   explain the gap.2. At account level, return an approved pseudonymous account key, net   revenue, direct costs, allocated costs, contribution profit, and cost   coverage. Do not include names or raw identifiers. If the model cannot   support account-level costs, report the available grain instead.3. Roll up the same measures by segment and for the total. Show distinct   account counts and contribution margin. Calculate overall margin from   total profit divided by total net revenue; do not average account or   segment margins. State the revenue and cost numerators behind each total.4. Reconcile segment totals to the overall totals. Flag small samples,   missing costs, allocation assumptions, and any accounts or segments that   cannot be compared on the same basis. OUTPUTReturn the metric definitions, exact time windows, filters, query context,account-level results using pseudonymous keys, and segment and total tables.Separate observed changes from hypotheses about causes. Do not infer causesfrom correlation, create forecasts, or present fictional examples as queryresults. Recommend only follow-up checks that the available data can support.

How it works

1

Confirm the metric contract

Verify the finance-approved revenue measure, included adjustments, time field, currency, account grain, and cost allocation rule. Keep missing cost data distinct from a true zero.

2

Calculate account and segment contribution

Subtract direct and approved allocated service costs from net revenue for each account. Roll the same numerators up by segment and period, and calculate each margin from its own total revenue rather than averaging account margins.

3

Compare periods and investigate the mix

Compare the last complete quarter with the previous quarter of equal length. Check cost coverage, segment membership, and the underlying service inputs before suggesting an explanation; the observed pattern alone does not establish a cause.

Where Q3 contribution profit came from

The chart and table use fictional values for July 1 through September 30, 2026. They compare net revenue, direct and approved allocated service costs, and contribution profit by segment; the overall margin uses total net revenue as its denominator.

Worked example: fictional Q3 2026 contribution profit by segment
SegmentAccountsNet revenueApproved costsContribution profitContribution margin
Starter10$30,000$18,000$12,00040.0%
Growth8$64,000$32,000$32,00050.0%
Enterprise4$120,000$54,000$66,00055.0%
Total22$214,000$104,000$110,00051.4%
  • Across 22 fictional accounts, $214,000 net revenue minus $104,000 approved service costs leaves $110,000 contribution profit. Overall contribution margin is $110,000 ÷ $214,000 = 51.4%; it is calculated from totals, not an average of segment rates.
  • Enterprise accounts contribute $66,000 of $110,000 total contribution profit (60.0%) from $120,000 of $214,000 revenue (56.1%), across 4 of 22 accounts. This describes the fictional mix; it does not explain why the segment differs.
  • Starter's fictional contribution margin is 40.0%, compared with 50.0% for Growth and 55.0% for Enterprise. Confirm the allocation basis and cost coverage before treating the gap as an operating insight.

This hand-calculated example and its image use fictional values only; they are not query results, customer results, a benchmark, or a prediction. Actual analysis depends on finance-approved revenue definitions, complete cost coverage, and the allocation basis in your model.

Frequently Asked Questions

Subtract approved direct service costs and approved allocated service costs from net revenue for the same customer and period. The revenue policy and cost scope need finance approval; contribution profit does not include every expense used to calculate net income.

Try Cube for free