如何在 MDX 中获取分区的唯一且唯一的最后日期的数据

How to get Data of Only and Only Last Date of Partition in MDX

我需要一种方法来获取分区中最后一个日期的最后一个数据。 Internet 上的所有资源都使用下面的代码块来应对这一挑战:

  with member [Measures.LastData]
  (
      [Measures].[Measure Name]
     ,
      Tail(filter([Dim Date Time].[Int Date].children,not IsEmpty( 
      [Measures].
  [Measure Name])))
  ).item(0)

但是我不需要这个代码。此代码仅获取日期每个数据的最后一个非空数据。

如果我们向它注入一些维度成员并且如果我们没有最后一个日期的数据,那么 Date-1 已经看到,如果不存在,Date -2 和 ...

例如我们有

日期名称价格

2017-01-01 马赫迪 20000

2017-01-01阿里10000

2017-01-02 马赫迪 30000

2017-01-02 穆罕默德50000

那我只想有 2017-01-02 - mahdi 和 mohammad 而不是 ali 在 2017-01-01

我回答我的问题

    CREATE HIDDEN SET CURRENTCUBE.[ProcessedDate] AS 
    (       
    FILTER
    (
        [DimWsDateTime].[Int Date].[Int Date].Members,
        (InStr(1, [DimWsDateTime].[Int Date].CurrentMember.NAME, 

            TAIL(
                    NONEMPTY(
                        [DimWsDateTime].[Int Date].[Int Date]
                        ,
                        [Measures].[Faultvalue]
                    )
                    ,1
                ).Item(0).MemberValue
    ) <> 0) 
    )); 



    WITH MEMBER  [measures].[IsOtherDimensionNotuse_] as
        Count(existing [DimWsDateTime].[Int Date].[Int Date].Members) = Count([DimWsDateTime].[Int Date].[Int Date].Members)

        MEMBER [measures].[SuccessRatioToAll_] as 
        (([Measures].[RecordCount] - [Measures].[Is Fault Activity])/[Measures].[RecordCount])

        MEMBER [measures].[LastvalueSuccessRatioToAll] as 
        (
            CASE WHEN [IsOtherDimensionNotuse_] then
               (
                    (
                        [Measures].[SuccessRatioToAll_]
                        ,
                        [ProcessedDate]
                     ).item(0)
                )
                else
                    measures.[SuccessRatioToAll_]
            end
        )
    select [measures].[LastvalueSuccessRatioToAll] on 0 from [MohebWebSrviceDetails]