Computed Columns
Create and use computed columns to derive new metrics from your existing data.
Computed columns let you define derived values that don’t exist in your database but can be calculated from existing columns. This enables the agent to answer questions about metrics like revenue, profit margins, and other calculated fields.
When to use computed columns
Section titled “When to use computed columns”Use computed columns when:
- A common metric isn’t stored as a column (e.g. order total, profit margin)
- Users ask questions using business terms that map to a calculation
- You want the agent to use a specific formula consistently
Example: Order total
Section titled “Example: Order total”Given an orders table with subtotal, discount, and tax columns but no total column:
total = subtotal - discount + taxAfter adding this computed column, users can ask:
- “What was our total revenue last month?”
- “What’s the average order total for customers in New York?”
- “Show me orders with a total over $500”
Example: Profit margin
Section titled “Example: Profit margin”Given a products table with price and cost columns:
profit_margin = (price - cost) / price * 100Now the agent can answer:
- “What’s our average profit margin?”
- “Which products have a margin below 20%?”
Adding via the Dashboard
Section titled “Adding via the Dashboard”- Go to Configure in the Inconvo dashboard
- Select the table you want to add a computed column to
- Click Add Computed Column
- Enter the column name and expression
- Optionally set a unit (e.g.
USD,%)
Adding via the CLI
Section titled “Adding via the CLI”npx inconvo model computed \ --agent agt_123 \ --connection conn_456 \ --payload '{"table": "orders", "name": "total", "expression": "subtotal - discount + tax", "unit": "USD"}'Combining with table prompts
Section titled “Combining with table prompts”Computed columns work best alongside table prompts. For example, if you add a total computed column on the orders table, also add a table prompt:
Revenue is calculated as the sum of the
totalcomputed column. Average order value (AOV) is the average oftotal.
This ensures the agent uses the correct column when users ask about “revenue” or “AOV”.