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.
| Metric | Illustrative example |
|---|---|
| Net recognized revenue | Q3 total: $214,000 after the approved discounts, credits, and refunds. |
| Direct and allocated service costs | Q3 total: $104,000, using direct costs plus only finance-approved allocations. |
| Customer grain and segment | 22 distinct accounts: 10 Starter, 8 Growth, and 4 Enterprise. |
| Segment contribution profit | Starter: $30,000 net revenue − $18,000 costs = $12,000. |
| Overall contribution margin | $110,000 contribution profit ÷ $214,000 net revenue = 51.4%. |
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.
Connect over MCP
Connect your agent to your existing Cube deployment and sign in through OAuth.
https://cubecloud.dev/mcp
Complete OAuth in your agent to connect your Cube account.
Use your default deployment or select another one available to your account.
Connect with CLI
Install the Cube CLI and sign in from a terminal-capable agent.
curl -fsSL https://raw.githubusercontent.com/cube-js/cube/master/install-cli.sh | sh
cube login --url https://TENANT.cubecloud.dev
cube spec --json
02Run this prompt in your agent
Choose your agent and copy the prompt below.
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
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.
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.
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.
| Segment | Accounts | Net revenue | Approved costs | Contribution profit | Contribution margin |
|---|---|---|---|---|---|
| Starter | 10 | $30,000 | $18,000 | $12,000 | 40.0% |
| Growth | 8 | $64,000 | $32,000 | $32,000 | 50.0% |
| Enterprise | 4 | $120,000 | $54,000 | $66,000 | 55.0% |
| Total | 22 | $214,000 | $104,000 | $110,000 | 51.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.