STPS Syntax
The STPS syntax language is
meant to be similar to the Excel Macro language. It enables you to
select time members based on logical calendar patterns on business logic
focused selection criteria such as last week or last quarter. In
contrast, regular dimensions do not support the ability to select
dimension members in this way.
Time members are always
resolved to leaf members in the cube. For instance, if a month of time
is selected and the cube has members stored in days, a collection of all
days in that month will be returned. Likewise, if that cube stores data
with hour granularity, all hours in that month will be returned
instead.
Note
When dealing with
non-English builds of PPS, it is important to note that the STPS
language is not localized into different languages. For example, a
Japanese installation of PPS still uses the English terms for members
and functions.
Language Form
For those who are mathematically inclined, the
formal declaration of the STPS syntax is as follows:
<TI_Expression> ::= <MemberExpression> , <TI_Expression> | <MemberExpression> :
<MemberExpression>
For the rest of us, this means
that a TI expression is a combination of time members. Time members, can consist of relative dates
such as yesterday, relative date ranges such as last month, and
functions such as quarter to date.
Time Members
Time members, which
correspond to logical date units, are the core building blocks for the
STPS syntax. Listed here are the levels of granularity available for
users, which are referred to as members
in the STPS syntax.
Caution
Members are available for use
only if they have been configured in the data source. For example, if
you configure an Analysis Services data source that only contains Year,
Month, and Day levels, the Semester and Quarter members will result in
errors if you attempt to use them.
Year
Semester
Quarter
Month
Week
Day
Hour
Minute
Second
Tip
Although granularity down
to the minute and second is included, it does not have many practical
applications. Given the default caching times of 10 minutes, and overall
performance of PPS, it is probably a good idea to stay with hour or
greater granularity when using time intelligence.
Operators
The colon and comma are
two operators used with time intelligence. These operators can be used
to combine various members and functions of the STPS syntax. Table 1 summarizes the STPS operators you can use.
Table 1. STPS Operators
Operator | Usage |
---|
Colon (:) | The
colon is used to indicate a range of dates. For example, the statement Day-1:Day-7 selects all the days between yesterday and a week
ago inclusively. |
Comma (,) | The
comma is used to combine two members. For example, the statement Day-1,Day-7 selects today and a week ago today as distinct
dates. |
Functions
Several functions are
available for traversing members. All parent and child references are
relative to the configuration of the data source. For example, if a week
level is configured directly above the day level, the Day.Parent function returns the current week. If there is no
week configured and the next configured level up is a month, it returns
the current month. The same applies to child references. Table 2
summarizes these functions.
Table 2. STPS Functions
Function | Description | Example Expression | Example Result |
---|
Parent | The parent of the
specified member. | Day.Parent | Week |
FirstChild | The first child of the
specified member. | Month.FirstChild | First day of month |
LastChild | The last child of the
specified member. | Month.LastChild | Last day of month |
First<Member> | Returns
the first child member of the parent time period.
Any member must be below the referenced member; otherwise, the
expression will not be valid. For example, Week.FirstYear will
return an error. | (Year-1).FirstWeek | First week of the
previous year |
Last<Member> | Returns the last
child member of the parent time period.
Any member must be below the referenced member; otherwise, the
expression will not be valid. For example, Week.FirstYear
returns an error. | (Month-1).LastDay | The
last day of last month |
<Member>ToDate | Returns
the range of dates between the beginning of the current period and now.
Note that this function only supports members down to the Day level.
This means that HourToDate, MinuteToDate, and SecondToDate
are not valid expressions. | QuarterToDate | All days up until the current quarter |
Full<Member> | Returns
the last full period as specified by the member.
Full is determined by calendar
days, not by data in the data source. For example, FullMonthmonth-1). However, in some cases it returns the previous
parent periods last month. normally returns last month (
This function is primarily
included to handle boundary cases around the beginning of periods when
used in conjunction with the <Member>ToDateYearToDate.Month-1 is
correct in all months except for January, in which case it returns an
error because there are no months ahead of January in the current Year. functions.
For example,
YearToDate.FullMonth. | YearToDate.FullQuarter | The last full quarter for
the current year |
Caution
Be careful of the FirstChild and LastChild functions. They work just fine until the
data source definition changes to add in new levels. For a more robust
implementation, stay with expressions that use members rather than the
parent/child relationship where possible.
Note
The Full<Member>
and <Member>ToDate functions are
new with PPS 2010. All the other functions come from PPS 2007.