Loading...

Gross Margin by Channel

Gross margin % by sales channel is one of the most frequently requested numbers in a monthly performance review — and one of the most frequently recomputed from scratch. This Decision Intelligence Agent answers it on demand, consistently, from the same system of record every time.

A Sales Manager spending 45–90 minutes before every monthly performance summary manually exporting sales data, filtering by channel, and recomputing gross margin % is not doing sales management. They are doing data retrieval. The KWF cognitive labor breakdown for this workflow puts 50% of the task in the execution layer — pulling from the data warehouse, applying the margin formula, formatting the result. None of that requires a Sales Manager's judgment. All of it currently gets one.

Interactive Demo

Try the Agent

Select a preset query to run the agent. Responses use the KWF-generated configuration and sample data — no live database connection required for this demo.

Agent Playground · Sales Channel Gross Margin %
KWF Runtime
Start with an example
Ready to run this agent on your data?
Request a live session — we'll configure the agent for your workflow, customize the logic at your direction, and deploy it to your Databricks environment before the session ends.
Deploy this Agent on Databricks
Agent Behavior

What the Agent Does

The agent handles one workflow at the execution layer: return a single, defensible gross margin percentage for one sales channel over a specified time window. This is a point query — not a dashboard, not a narrative, not a recommendation. The agent's job is to get the Sales Manager to the point where a judgment-layer conversation is possible, in seconds instead of an hour.

1
Input
Receive sales channel name and date window (explicit dates or resolved from "last month")
2
Retrieve
Query fact_sales in Databricks, filter by channel and date window, sum revenue and profit
3
Compute
Calculate gross margin % = total profit ÷ total revenue; handle no-data case
4
Output
Return a single, formatted sentence: "Retail gross margin for March 2026 was 47.6%."

The output is not a dashboard. It is one sentence, sourced from one query, against one table, using one formula. The value is not in the complexity of the output — it is in the consistency and availability. Every Sales Manager on the team uses the same number. Finance uses the same number. The QBR deck uses the same number. The argument about whose spreadsheet is right stops.

What this agent does NOT do: It does not interpret whether the margin is acceptable. It does not flag discounting patterns. It does not recommend channel investment shifts. Those are judgment and strategic calls — and they are explicitly out of scope for this agent. The agent's job is to answer the question so the Sales Manager can spend their time deciding what to do about the answer.
Under the Hood

Agent Configuration & Data

Every agent configuration generated by the Knowledge Work Foundry includes the query logic, data schema, and sample output. What you see below is the actual KWF output for this workflow candidate.

-- KWF Agent Query: Last-Month Gross Margin % by Sales Channel
-- Parameters: {sales_channel}, {start_date}, {end_date}
-- Runtime resolves relative phrases like "last month" to explicit dates
-- Table: pura_vida_foods_dev.sales_dw.fact_sales

SELECT
  '{sales_channel}' AS sales_channel,
  SUM(revenue)                               AS total_revenue,
  SUM(profit)                                AS total_profit,
  CASE
    WHEN SUM(revenue) = 0 THEN NULL
    ELSE ROUND(SUM(profit) / SUM(revenue), 4)
  END                                         AS gross_margin_pct
FROM  pura_vida_foods_dev.sales_dw.fact_sales
WHERE sale_date BETWEEN '{start_date}' AND '{end_date}'
  AND   sales_channel = '{sales_channel}';

-- Business logic:
-- If gross_margin_pct IS NULL → "No sales for {channel} in this period."
-- Otherwise → format as percentage (× 100, one decimal): "47.6%"
-- Use this value verbatim across Sales, Finance, and Ops to prevent recomputation
-- Source table: pura_vida_foods_dev.sales_dw.fact_sales
-- Delta table on Databricks — precomputed revenue and profit columns
-- Agent reads only: revenue, profit, sale_date, sales_channel

CREATE OR REPLACE TABLE pura_vida_foods_dev.sales_dw.fact_sales (
  sale_id          STRING           NOT NULL,
  sale_date        DATE             NOT NULL,
  customer_id      STRING           NOT NULL,
  product_id       STRING           NOT NULL,
  order_id         STRING           NOT NULL,
  quantity         DECIMAL(10,2)    NOT NULL,
  unit_price       DECIMAL(10,2)    NOT NULL,
  unit_cost        DECIMAL(10,2)    NOT NULL,
  revenue          DECIMAL(15,2)    NOT NULL,  -- precomputed
  cost             DECIMAL(15,2)    NOT NULL,  -- precomputed
  profit           DECIMAL(15,2)    NOT NULL,  -- precomputed
  profit_margin    DECIMAL(8,4),
  discount_amount  DECIMAL(10,2)    DEFAULT 0.00,
  discount_percent DECIMAL(5,2)     DEFAULT 0.00,
  sales_channel    STRING,                     -- Retail | Wholesale | Online
  order_priority   STRING,
  shipping_cost    DECIMAL(10,2)    DEFAULT 0.00,
  created_at       TIMESTAMP,
  updated_at       TIMESTAMP
)
USING DELTA;

Sample query result for Retail channel, March 2026. The agent formats gross_margin_pct as a percentage and uses it verbatim in the response sentence.

sales_channel total_revenue total_profit gross_margin_pct formatted_answer
Retail 299.70 142.70 0.4760 "47.6%"
Response sentence: "Retail gross margin for 2026-03-01 to 2026-03-31 was 47.6%."

No-data case: If gross_margin_pct is NULL (zero revenue in window), the agent returns: "No sales recorded for [channel] in [period]."
Agent configuration generated by Knowledge Work Foundry
Knowledge Work Foundry Analysis

Cognitive Labor Breakdown

The KWF analyzes every workflow candidate across three layers of cognitive labor. The split below is the actual output of the KWF analysis for the Last-Month Gross Margin % by Sales Channel workflow for a Sales Manager role.

Execution 50% Judgment 35% Strategic 15%
Layer Share What It Is Automated?
Execution 50% Exporting sales data, filtering by channel and date window, applying the margin formula, formatting the result for the deck or email Fully automated
Judgment 35% Interpreting whether the margin is acceptable given product mix and discounting patterns; deciding which channel movements warrant action in the performance review Elevated to human
Strategic 15% Deciding channel investment shifts — promotional spend, sales coverage, pricing adjustments — consistent with margin preservation targets Human-only

The execution layer is rule-following: retrieve from one table, apply one formula, format to one decimal. The logic is defined and has been for years — it just hasn't been encoded anywhere. So the Sales Manager encodes it manually, from memory, every month.

The judgment layer is where the Sales Manager's time actually belongs. Deciding whether a margin compression in the Retail channel reflects a product mix shift or a pricing concession that needs to be unwound is a Sales Manager call. Building the spreadsheet that produces the number is not.

Generated by Knowledge Work Foundry
Value Model

Business Value Translation

Redirecting the execution layer of this workflow to the agent does not "save 45 minutes per month." It changes what a Sales Manager does before every performance summary and QBR. Instead of arriving having built the margin view, they arrive having read it — and the conversation starts at the judgment layer: what to do about the channel movements, not what the numbers are.

Incremental business value generated
$202,000 / year
Annual value gain from redirecting freed time to judgment and strategic work — same team, same salaries
Value increase
+12.7%
more value from the same labor cost
ROI on investment
8.1×
value gain per dollar spent on automation
Net annual benefit
$177k
after deducting full automation cost ($25k/year)
Team modeled
3
Sales Managers at $160k fully loaded cost
Value model assumptions
Layer allocation (E / J / S) 50% / 35% / 15%
Automation coverage (α) 0.20 — narrow point-query, one KPI
Freed time fraction (Δ = E × α) 0.10 — 10% of each person's time elevated
Value multipliers (pJ / pS) 3× / 7× — conservative planning-level floor
Annual automation cost (CA) $25,000 / year for the full team

These multipliers are conservative planning-level estimates representing the lower end of the established ranges. The value case is typically stronger in practice. Use the calculator to model your specific team size and cost structure.

At the three-layer value model, execution work generates roughly 1× value per dollar of labor cost. Judgment work generates 2–5×. Strategic work generates 5–15×. A team of Sales Managers whose execution allocation for this workflow drops from 50% to ~40% is not saving time — they are redirecting high-cost resources to the work that actually leverages their expertise. For a team that runs monthly channel reviews, this is the difference between a meeting that starts at the numbers and one that starts with the decisions.

Next Step

Run your own value estimate — or talk to us about your team.

The Cognitive Labor Value Calculator models exactly what this workflow shift is worth for your team size, your role cost, and your automation coverage. Takes under two minutes.