- name: total_revenue
  display_name: Total Revenue
  category: revenue
  type: sum
  unit: USD
  grain: monthly
  time_column: order_date
  table: orders
  expression: "SUM(total_amount)"
  description: "Total revenue from all orders. Primary top-line metric tracking overall business performance across all channels and product categories."
  dimensions:
    - channel
    - product_category
    - region
    - payment_method
  notes:
    - "Includes all completed orders, excludes cancelled and refunded"
    - "Revenue is recognized at order completion date, not payment date"
    - "Multi-currency orders are converted to USD at daily exchange rate"
  synonyms:
    - gross_revenue
    - total_sales
    - top_line_revenue
  sql: |
    SELECT
        DATE_TRUNC('month', order_date) AS month,
        SUM(total_amount) AS total_revenue
    FROM orders
    WHERE status = 'completed'
    GROUP BY 1
    ORDER BY 1
  sql_by_channel: |
    SELECT
        DATE_TRUNC('month', order_date) AS month,
        channel,
        SUM(total_amount) AS revenue
    FROM orders
    WHERE status = 'completed'
    GROUP BY 1, 2
    ORDER BY 1, 3 DESC
