MDX: How to Retrieve data Based on Latest Date For Each Student Id

半城伤御伤魂 提交于 2019-12-11 02:29:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!