Getting all the months of the 2010 year starting with the first month [Jan 2010] and ending with the specified member: [Jun 2010].
Query
PeriodsToDate([Time].[Calendar].[Year],[Jun 2010])
Result
{
[Time].[Calendar].[Month].[Jan 2010],
[Time].[Calendar].[Month].[Feb 2010],
[Time].[Calendar].[Month].[Mar 2010],
[Time].[Calendar].[Month].[Apr 2010],
[Time].[Calendar].[Month].[May 2010],
[Time].[Calendar].[Month].[Jun 2010]
}
Assertion : MDX Equals
{[Jan 2010] : [Jun 2010]}
Assertion : MDX Equals
{ OpeningPeriod( [Jun 2010].level, Ancestor([Jun 2010],[Time].[Calendar].[Year]) ) : [Jun 2010] }
PeriodsToDate can also be used with non-time dimensions.
Query
PeriodsToDate([Geography].[Geo].[Country],[Geography].[Geo].[Mexico])
Result
{
[Geography].[Geo].[Country].[Mexico]
}
Assertion : MDX Equals
{ OpeningPeriod( [Geography].[Geo].[Mexico].level, Ancestor([Geography].[Geo].[Mexico],[Geography].[Geo].[Country]) ) : [Geography].[Geo].[Mexico] }
If no member is specified then [Time].CurrentMember is used instead.
Query
WITH
MEMBER period_names AS GENERATE( PeriodsToDate( [Time].[Calendar].[Year] ) as periods , periods.CurrentMember.Name, "-" )
SELECT
period_names ON 0
FROM
[Sales]
WHERE
[Time].[Calendar].[Aug 2010]
Result
period_names |
Jan 2010-Feb 2010-Mar 2010-Apr 2010-May 2010-Jun 2010-Jul 2010-Aug 2010 |
Assertion : MDX Equals
WITH
MEMBER period_names AS GENERATE( PeriodsToDate( [Time].[Calendar].[Year], [Time].[Calendar].currentMember ) as periods , periods.CurrentMember.Name, "-" )
SELECT
period_names ON 0
FROM
[Sales]
WHERE
[Time].[Calendar].[Aug 2010]
If both the level and the member are not specified, then [Time].currentMember is used as the
member expression and its parent level as the level expression.
Query
WITH
MEMBER period_names AS GENERATE( PeriodsToDate() as periods , periods.CurrentMember.Name, "-" )
SELECT
period_names ON 0
FROM
[Sales]
WHERE
[Time].[Calendar].[Aug 2010]
Result
period_names |
Jul 2010-Aug 2010 |
Assertion : MDX Equals
WITH
MEMBER period_names AS GENERATE( PeriodsToDate( [Time].[Calendar].CurrentMember.Parent.Level, [Time].[Calendar].CurrentMember ) as periods , periods.CurrentMember.Name, "-" )
SELECT
period_names ON 0
FROM
[Sales]
WHERE
[Time].[Calendar].[Aug 2010]