问题

How to get latest count based on date for each id.
Attempt:
SELECT [Measures].[CourseJoinedCount] ON COLUMNS,
NON EMPTY
(
[Course].[CourseName].[CourseName],
[DimDate].[Full Date].[Full Date],
[Student].[StudentId].[StudentId]
)ON ROWS
FROM [RandD]
回答1:
I think the use of Generate
might help. Currently untested but I will try an mock this up against AdvWrks
tomorrow to see if it works:
SELECT
NON EMPTY
[Measures].[CourseJoinedCount] ON 0,
Generate(
[Course].[CourseName].[CourseName].MEMBERS
,[Course].[CourseName].CURRENTMEMBER
*Tail(
NonEmpty(
[DimDate].[Full Date].[Full Date].MEMBERS,
[Course].[CourseName].CURRENTMEMBER
)
)
)
*[Student].[StudentId].[StudentId]
ON 1
FROM [RandD];
来源:https://stackoverflow.com/questions/36132898/mdx-how-to-retrieve-data-based-on-latest-date-for-each-student-id