slice¶
Extract a subset of a vector variable.
slice(
vector,
startIndex,
endIndex,
)
This is normally used inside another function such as
sum
or average.
Arguments¶
vector- The vector to slice.
startIndex- The first index to retrieve from the vector. Inclusive.
endIndex- The last index to retrieve from the vector. Inclusive.
Examples¶
These forms select indices 2 through 5, including both endpoints:
sum(slice(VectorA, 2, 5))
sum(VectorA[2:5])
sum(VectorA[2]:VectorA[5])
Bounds may be scalar variables or expressions. If Two=2 and Five=5,
these forms select indices 1 through 4:
sum(VectorA[Two-1:Five-1])
sum(VectorA[(Two-1):(Five-1)])
sum(VectorA[Two-1]:VectorA[Five-1])
For example, AVERAGE(MonthlyWage[RetAgeT-12:RetAgeT-1])
averages the twelve months preceding RetAgeT.
slice() caps the start index at 1 and the end index at ProjMonths.
Bracket indexing does not cap the bounds; an index outside the vector produces an Excel reference error.
Both bounds are required. Omitted bounds (VectorA[:5]),
steps (VectorA[1:5:2]), and multiple subscripts (VectorA[1,2]) are unsupported.
When Autory detects an unsupported indexing formula during workbook generation,
it writes an error cell and logs an explanation so other results remain available.
See the example workbook.