create a calculated measure in MDX that Filters by Date Range

試著忘記壹切 提交于 2019-12-08 19:27:28

I had a similar task and end up with the following solution:

SUM(
    [EmployeeChanging].[EmployeeChanging].[EmployeeChanging].Members,
    IIF(
        [Measures].[EmployeeFrom] <= [Measures].[MaxDay]
        and 
        [Measures].[EmployeeTo] >= [Measures].[MinDay],
        [Measures].[EmployeeChangingCount],
        NULL
    )
)

There is the dim/fact table in the following format:

EmployeeID + StartDate + EndDate

Create a new dimension EmployeeChanging where the key is EmployeeID + StartDate and a measure group based on the same table with [Measures].[EmployeeFrom],[Measures].[EmployeeTo],[Measures].[EmployeeChangingCount] measures with max, max, count aggregations. Also you have to provide [Measures].[MaxDay] and [Measures].[MinDay] measures based on your Date dimension with max and min aggregations for the same date field. That's it. Also you may hide your EmployeeChanging dimension as it required only for MDXing.

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