About Dive Windows
A window in a Spectre Dive displays the data that is retrieved in a dive. The window has zero or more dimensions, which are the fields used to generate the rows in the window. There is a column for each dimension, and each row in the window has a unique combination of values in the dimension columns. The values in the non-dimension columns, which are known as summaries, are usually computed by running a summary expression over all of the cBase records that match that unique combination of dimension values.
Calculated Columns in Dive Windows
The dimensions in a Dive window come from columns in the underlying cBases. You can use the dimensions in calculations. For example, if you have a cBase column for Order Date but not Order Month, then you can define Order Month with a calculation like this:
calc "Order Month" `info(period("standard", "year-month", value("Order Date")))`
This column can be included in a Dive window:
window { dimension "Order Date" column "Order Month" ... }
However, diving is not supported on the calculated column, Order Month. You can either add an Order Month column in your source data (for example, using Integrator), or you can use an add tag in the Build script and recreate the cBase:
build { text-input "sales.txt" { ... } add "Order Month" `period("standard", "year-month", value("Order Date"))` ... }
Expression Dimensions in Dive Windows
Another way to add a column to a Dive window is to add an expression dimension to generate a new dimension at dive time. The expression needs to be specified in a cPlan and associated with a new dimension name. When a Dive file runs referring to the cPlan, the expression dimension is then automatically calculated and becomes a divable dimension. For example, a dimension could be added to the cPlan like this:
cplan { input "sales.cbase" dimension "Order Month" `period("standard", "year-month", value("Order Date"))` }
and then used in a dive with a dimension tag.:
window { dimension "Order Month" ... }
This is using the expression dimension as a dimension in a dive. It could also be used as a summary column. For example:
cplan { text-input "one.txt" name="one" text-input "two.txt" name="two" text-input "three.txt" name="three" dimension "C" `value("A") + value("B")` }
and then used in a dive with a column tag:
window { column "any C" `info(substr(value("C"), 1, 1))` }
NOTE: If a cPlan has an expression dimension with multiple inputs, a summary uses the first input that has all the columns it requires. This means, if you have input 1 with column A and input 2 with columns A and B and you have two summaries, one using just A and one using A and B, the first summary will run on input 1 and the second summary will run on input 2. The summaries will get values for A from different sources.
See also: