The following example returns the sum of the Measures.[Order Quantity] member, aggregated over the first eight months of calendar year 2003 that are contained in the Date dimension, from the Adventure Works cube.
WITH MEMBER [Date].[Calendar].[First8Months2003] AS
Aggregate(
PeriodsToDate(
[Date].[Calendar].[Calendar Year],
[Date].[Calendar].[Month].[August 2003]
)
)
SELECT
[Date].[Calendar].[First8Months2003] ON COLUMNS,
[Product].[Category].Children ON ROWS
FROM
[Adventure Works]
WHERE
[Measures].[Order Quantity]
The following example aggregates over the first two months of the second semester of calendar year 2003.
WITH MEMBER [Date].[Calendar].[First2MonthsSecondSemester2003] AS
Aggregate(
PeriodsToDate(
[Date].[Calendar].[Calendar Semester],
[Date].[Calendar].[Month].[August 2003]
)
)
SELECT
[Date].[Calendar].[First2MonthsSecondSemester2003] ON COLUMNS,
[Product].[Category].Children ON ROWS
FROM
[Adventure Works]
WHERE
[Measures].[Order Quantity]
The following example returns the count of the resellers whose sales have declined over the previous time period, based on user-selected State-Province member values evaluated using the Aggregate function. The Hierarchize and DrillDownLevel functions are used to return values for declining sales for product categories in the Product dimension.
WITH MEMBER Measures.[Declining Reseller Sales] AS
Count(
Filter(
Existing(Reseller.Reseller.Reseller),
[Measures].[Reseller Sales Amount] < ([Measures].[Reseller Sales Amount],
[Date].Calendar.PrevMember)
)
)
MEMBER [Geography].[State-Province].x AS
Aggregate (
{[Geography].[State-Province].&[WA]&[US],
[Geography].[State-Province].&[OR]&[US] }
)
SELECT NON EMPTY Hierarchize (
AddCalculatedMembers (
{DrillDownLevel({[Product].[All Products]})}
)
)
DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON COLUMNS
FROM [Adventure Works]
WHERE ([Geography].[State-Province].x,
[Date].[Calendar].[Calendar Quarter].&[2003]&[4],
[Measures].[Declining Reseller Sales])