Generated Time Series Columns

This example illustrates how the time series columns are generated by the Spectre syntax.

cplan {
  input "time-series.cbase"

  calc "Dollars" `sum(value("Price")*value("Units"))` label="$" format="$#,0.00"
  
  // The time series can be named, so that two different time series do not
  // produce conflicting columns. The label is part of the column name.
  time-series label="TS" {
    date "Order Date"
    anchor `date("2017/06/04")`
    
    // produce time series for both "Units" and "Dollars"
    summary "Units"
    summary "Dollars"
    
    // for each summary, produce YTD, MTD, M, and Q columns
    ranges {
      year-to-date
      month-to-date
      current-month
      current-quarter
    }
    
    // for each summary and range, also produce LY, TY Diff, and TY % Diff columns
    variations {
      previous-year {
        difference
        percent-difference
      }
    }
    
    // Put all the columns into a calc-set, for easy reference in a dive script
    calc-set "Time Series"
  }

}

This time series definition results in 16 different columns for each summary. For example, for the first range year-to-date:

TS Units YTD Units summary, range year-to-date
TS Units YTD LY variation: previous-year
TS Units YTD TY Diff variation: previous-year difference
TS Units YTD TY % Diff variation: previous-year percent-difference
TS $ YTD Dollars summary calc has a label="$", range year-to-date
TS $ YTD LY variation: previous-year
TS $ YTD TY Diff variation: previous-year difference
TS $ YTD TY % Diff variation: previous-year percent-difference

The pattern repeats for the other three ranges listed: month-to-date, current-month, and current-quarter:

TS Units MTD TS $ MTD
TS Units MTD LY TS $ MTD LY
TS Units MTD TY Diff TS $ MTD TY Diff
TS Units MTD TY % Diff TS $ MTD TY % Diff
TS Units M TS $ M
TS Units M LY TS $ M LY
TS Units M TY Diff TS $ M TY Diff
TS Units M TY % Diff TS $ M TY % Diff
TS Units Q TS $ Q
TS Units Q LY TS $ Q LY
TS Units Q TY Diff TS $ Q TY Diff
TS Units Q TY % Diff TS $ Q TY % Diff