cubes:
  - name: orders
    sql: "SELECT * FROM orders"
    dimensions:
      - name: id
        type: number
        sql: id
        primary_key: true
      - name: created_at
        type: time
        sql: created_at
        granularities:
          # Single-unit intervals with an explicit origin. The origin has to survive into the
          # grouping, or every row lands on the natural boundary of the interval's own unit.
          - name: fiscal_year_by_1st_april
            interval: "1 year"
            origin: "2024-04-01"
          - name: calendar_year_by_origin
            interval: "1 year"
            origin: "2024-01-01"
          - name: monthly_from_15th
            interval: "1 month"
            origin: "2024-01-15"
    measures:
      - name: count
        type: count
      - name: total_amount
        type: sum
        sql: amount
      - name: total_amount_prior_year
        type: number
        sql: "{CUBE.total_amount}"
        multi_stage: true
        time_shift:
          - time_dimension: created_at
            interval: "1 year"
            type: prior
