> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wayak.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Material usage variance

> Track actual material consumption against bills of materials to catch waste and pricing discrepancies

Material costs typically account for 50-70% of total manufacturing cost. Even small variances — an extra kilogram of resin per batch, a substitution at a higher unit price, or a scrap rate that creeps up by half a percent — add up fast across hundreds of production runs. Most teams only catch these during monthly cost reviews, long after the opportunity to intervene has passed.

This use case connects your ERP and inventory data to a Wayak agent that compares actual material consumption against BOM standards. A weekly playbook uses Python to calculate quantity and price variances for every material, flag the largest deviations, and deliver a report your procurement and production teams can act on immediately.

***

## What you need

<CardGroup cols={2}>
  <Card title="Data sources" icon="database">
    * **ERP system** — Bills of materials (BOMs) with standard quantities, material issue transactions, and standard cost records
    * **Inventory management system** — Current stock levels, material receipts with actual unit prices, and lot tracking data
  </Card>

  <Card title="Knowledge spaces" icon="book-open">
    * **BOM standards documentation** — Upload your standard BOM definitions and approved material substitution lists
    * **Procurement policies** — Price variance thresholds and approved vendor lists for reference
  </Card>
</CardGroup>

**Semantic layer:** Define these in your ontology before setting up the agent.

| Component | Name              | Definition                                                                                                              |
| --------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------- |
| Object    | Material Issue    | Maps to ERP material issue transactions. Represents a single material withdrawal against a work order                   |
| Object    | BOM Line          | Maps to the bill of materials detail table. Represents the planned quantity of a material for one unit of finished good |
| Metric    | Quantity Variance | Actual quantity consumed minus standard quantity (from BOM), per work order or batch                                    |
| Metric    | Price Variance    | (Actual unit price minus standard unit price) multiplied by actual quantity consumed                                    |
| Dimension | Material Type     | Groups materials by category: raw materials, packaging, consumables, components                                         |
| Dimension | Supplier          | Groups material issues by the vendor who supplied the material lot                                                      |

<Tip>
  See [building a semantic layer](/quickstart/build-semantic-layer) for a step-by-step guide.
</Tip>

***

## Agent setup

<Steps>
  <Step title="Create the agent">
    Go to **Agent Space** > **New agent**.

    | Field    | Value                                                             |
    | -------- | ----------------------------------------------------------------- |
    | **Name** | Material Variance Analyst                                         |
    | **Role** | Material cost and usage analyst                                   |
    | **Goal** | Identify material consumption variances and pricing discrepancies |
  </Step>

  <Step title="Set the description">
    > You are a material cost analyst. When analyzing material usage, always separate quantity variance from price variance — they have different root causes and different owners. Present the largest dollar-impact variances first. For quantity variances, check whether a material substitution was made. For price variances, compare against the approved vendor price list. Use specific numbers: show the standard quantity, actual quantity, and difference. When variance exceeds 5% of standard cost, recommend an investigation and specify whether it is a production issue (quantity) or procurement issue (price).
  </Step>

  <Step title="Scope data access">
    Grant access to:

    * ERP system data source (BOMs, material issue transactions, standard costs)
    * Inventory management system data source (receipts and pricing)
    * BOM standards documentation knowledge space
    * Procurement policies knowledge space
    * Material Issue and BOM Line objects in the semantic layer
  </Step>

  <Step title="Add skills">
    <AccordionGroup>
      <Accordion title="Calculate material usage variance">
        **Trigger:** User asks about material variance, waste, or BOM compliance

        1. Identify the work order, product, or material from the user's request.
        2. Pull the BOM standard quantities for the finished good.
        3. Pull the actual material issue transactions for the specified work orders.
        4. Calculate quantity variance for each material line: actual quantity minus standard quantity.
        5. Calculate price variance for each material: (actual price minus standard price) multiplied by actual quantity.
        6. Sort by total dollar impact, largest first.
        7. Present a table with material name, standard quantity, actual quantity, quantity variance, standard price, actual price, and price variance.
      </Accordion>

      <Accordion title="Detect material substitutions">
        **Trigger:** User asks about substitutions or unexpected materials

        1. Pull all material issue transactions for the specified work orders.
        2. Compare issued material item numbers against the BOM's specified item numbers.
        3. Identify any material issued that does not appear on the BOM (potential substitution).
        4. Check the substitution against the approved substitution list in the knowledge space.
        5. Flag unapproved substitutions and include the cost difference versus the standard material.
      </Accordion>
    </AccordionGroup>
  </Step>
</Steps>

***

## Automation

### Playbook: Weekly material variance report

<Steps>
  <Step title="Set the trigger">
    Schedule the playbook to run every Monday at 7:00 AM.
  </Step>

  <Step title="Build the workflow">
    The playbook compiles the previous week's material consumption against BOM standards and highlights the largest variances.

    1. **Query step** — Pull all material issue transactions for work orders completed in the previous 7 days, along with corresponding BOM lines.
    2. **Python code step** — Calculate quantity variance and price variance for every material-work order combination. Aggregate to material level and rank by total dollar impact.
    3. **Condition step** — Filter to materials where total variance exceeds 5% of standard cost or \$500 in absolute terms.
    4. **Format step** — Build a report with two sections: top quantity variances (for production review) and top price variances (for procurement review).

    <Info>
      The **Python code step** uses a Python code block to compute both quantity and price variances, aggregate them by material, and rank by dollar impact. You can customize the variance thresholds and add trend calculations comparing to the previous week.
    </Info>
  </Step>

  <Step title="Configure delivery">
    Send the full report via email to the production manager and procurement lead. Include the total variance dollar amount in the subject line.
  </Step>

  <Step title="Test and activate">
    Click **Run now** to test with live data, then toggle to **Active**.
  </Step>
</Steps>

***

## What's next

<CardGroup cols={2}>
  <Card title="Work order cost tracking" icon="arrow-right" href="/use-cases/manufacturing/work-order-cost-tracking">
    Monitor overall production order costs and catch overruns before they escalate.
  </Card>

  <Card title="All manufacturing use cases" icon="list" href="/use-cases/manufacturing">
    See the full list.
  </Card>
</CardGroup>
