Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDX

Status
Not open for further replies.

NotSQL

Technical User
May 17, 2005
205
GB
hi I wondering if anyone can help.

I know the following syntax works,

SELECT ([Measures].[SALES]) on columns,
LastPeriods(3,[Date].[Hierarchy].[Year].&[2008].&[WK02]) ON Rows
FROM [TestCube]

however instead of hard coding the week part i want it to pick up the last member in the hierarchy.

Eg

SELECT ([Measures].[SALES]) on columns,
LastPeriods(3,[Date].[Hierarchy].[Year].[LastMemberWeek]) ON Rows
FROM [TestCube]

Hope someone can help
 
Have you tried the
Code:
Tail (Filter (...
functions

The Filter function should identify all the hierarchy members (in your case the week) with data, and the Tail will select the last one

EO
Hertfordshire, England
 
Untested but should work.

Code:
SELECT ([Measures].[SALES]) on columns,
LastPeriods(3,[Date].[Hierarchy].[Year].LastChild.LastChild) ON Rows
FROM [TestCube]

Remember when you post MDX code that .&[] is a unique Identifier and sometimes can make it difficult for someone else to deduce the structure of a dimension.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top