ivy: dashboard/v1
title: Sales
description: Revenue against target, from the monthly sales export in Reports/sales.csv.

sources:
  sales:
    file: Reports/sales.csv
  monthly:
    file: Reports/sales.csv
    group_by: [month]
    aggregate:
      revenue: { sum: revenue }
      target: { sum: target }
      units: { sum: units }
    sort:
      - { column: month }
  by_region:
    file: Reports/sales.csv
    group_by: [region]
    aggregate:
      revenue: { sum: revenue }
    sort:
      - { column: revenue, order: desc }
  by_product:
    file: Reports/sales.csv
    group_by: [product]
    aggregate:
      units: { sum: units }

widgets:
  - type: kpi
    title: Revenue
    source: sales
    value: revenue
    compare: { column: target, label: vs target }
    format: { style: currency, currency: EUR, decimals: 0 }
  - type: kpi
    title: Revenue last month
    source: monthly
    value: revenue
    aggregate: last
    compare: { label: vs the month before }
    format: { style: currency, currency: EUR, decimals: 0 }
  - type: kpi
    title: Units sold
    source: sales
    value: units
  - type: kpi
    title: Average units per sale
    source: sales
    value: units
    aggregate: avg
    format: { decimals: 1 }
  - type: line
    title: Revenue against target
    width: 8
    source: monthly
    x: month
    y: [revenue, target]
    format: { style: compact, date: month }
  - type: pie
    title: Units by product
    source: by_product
    label: product
    value: units
    donut: true
  - type: bar
    title: Revenue by region
    source: by_region
    x: region
    y: [revenue]
    format: { style: currency, currency: EUR, decimals: 0 }
  - type: table
    title: Months
    width: 6
    source: monthly
    columns:
      - { column: month, format: { date: month } }
      - { column: units }
      - { column: revenue, format: { style: currency, currency: EUR, decimals: 0 } }
      - { column: target, format: { style: currency, currency: EUR, decimals: 0 } }
    sort: { column: month, order: desc }
