Ssas 将sql列组转换为mdx列组

Ssas 将sql列组转换为mdx列组,ssas,mdx,Ssas,Mdx,这是我的sql代码-我想将其转换为mdx查询。 此外,这些结果将用于power bi报告。 我无法将此sql查询写入mdx查询。有人能帮我吗 Select * From( Select dense_RANK()over(partition by t.MonthName order by t.amount desc)rank ,t.* From( Select DSP.SalesPointShortName ,dd.MonthName

这是我的sql代码-我想将其转换为mdx查询。 此外,这些结果将用于power bi报告。 我无法将此sql查询写入mdx查询。有人能帮我吗

    Select * From(
    Select 
    dense_RANK()over(partition by t.MonthName order by t.amount desc)rank
    ,t.*
    From( 
    Select DSP.SalesPointShortName ,dd.MonthName 
    ,SUM(fs.salesAmount)Amount
      From FactSales FS
    INNER JOIN DimDate dd on fs.DateKey=dd.DateKey
    INNER JOIN DimSalesPoint DSP on DSP.SalesPointID=FS.SalesPointID
    group by dsp.SalesPointShortName ,dd.MonthName 
    )as t  
    )as f where f.rank=1
我的预期产出是:


大量的谷歌搜索我从下面的链接中得到了答案 跟随这个链接之后,渴望的结果就来了。

`

将[Sorted Models]设置为
//每个月获取前25名记录,从商业案例中选择前25名
生成(
[Dim Date].[Month Name].[Month Name]。成员,
头号人物
(非空(
{
[日期][月份名称].CurrentMember
*[Dim Sales Point].[SalesPoint].[Sales Point简称].成员
}
,[衡量标准][销售额]
) 
1.
,[衡量标准][销售额]
)
)
//挑选
//0上的[度量值][销售额],[1上的已排序模型]
//来自[MdCubeTest]
//其中【Dim产品组项目】【子类别名称】和【袋】
成员[度量][等级]为
//获取当前成员元组到当前月集的排名
//不要使用已排序的模型集,因为每个模型集都是动态的
排名(
(
[日期][月份名称].CurrentMember
,[Dim Sales Point].[SalesPoint].CurrentMember
)
,生成([Dim Date].[Month Name].CurrentMember,
头号人物
(非空(
{[Dim Date].[Month Name].CurrentMember
*[Dim Sales Point]。[SalesPoint]。[Sales Point简称]
}
,[衡量标准][销售额]
) 
, 25
,[衡量标准][销售额]
)
)
,[衡量标准][销售额]
)
成员[度量][上一组索引]为
//使用秩获取集合索引
( 
[措施][等级]-2
) 
成员[测量][密集等级]为
//使用索引位置值获取密集秩
案例
当[Measures].[Rank]=1时
那么1
其他的
( 
[Sorted Models]。项([Measures].[Previous Set Index]),
[措施][密集等级]
) 
+ 
Iif
( 
( 
[Sorted Models]。项([Measures].[Previous Set Index]),
[措施][销售额]
) 
= 
[措施][销售额]
,0 
1.
) 
终点
挑选
{
[措施][销售额]
,[度量][等级]
,[度量值][密集等级]
//,[Measures]。[Previous Set Index]
}成排
,非空
{
//过滤器可用于使用密集秩获得前3名
过滤器(
[分类模型]
,[度量值][密集等级]
 WITH SET [Sorted Models] AS
    // For each month get Top 25 records, choosed a Top 25 from business case
     Generate ( 
        [Dim Date].[Month Name].[Month Name].Members,
        TopCount 
          ( nonempty(
               {
                   [Dim Date].[Month Name].CurrentMember
                  * [Dim Sales Point].[SalesPoint].[Sales Point Short Name].MEMBERS              
                }
               ,[Measures].[Sales Amount] 
                 ) 
           , 1
           ,[Measures].[Sales Amount]
          )
          )
    //Select 
    //[Measures].[Sales Amount] on 0,[Sorted Models] on 1
   //From  [MdCubeTest]
   //where [Dim Product Group Item].[Sub Category Name].&[Bag]
    MEMBER [Measures].[Rank] AS
    // Get the Rank of current member Tuple to Current Month Set
    // Do not use Sorted Models set due to dynamic for each set
    Rank ( 
        (
        [Dim Date].[Month Name].CurrentMember 
        , [Dim Sales Point].[SalesPoint].CurrentMember    
        )
  ,  Generate ( [Dim Date].[Month Name].CurrentMember,
    TopCount 
      ( nonempty(
         { [Dim Date].[Month Name].CurrentMember
          * [Dim Sales Point].[SalesPoint].[Sales Point Short Name]          
                  }
           ,[Measures].[Sales Amount] 
           ) 
       , 25
       ,[Measures].[Sales Amount]
      )
     )
    , [Measures].[Sales Amount] 
    )

MEMBER [Measures].[Previous Set Index] AS
// Get the Set Index using Rank 
( 
[Measures].[Rank] - 2 
) 
MEMBER [Measures].[Dense Rank] AS
// Get the Dense Rank using the Index position value 
CASE
 WHEN [Measures].[Rank] = 1 
  THEN 1 
 ELSE
        ( 
        [Sorted Models].Item([Measures].[Previous Set Index]), 
        [Measures].[Dense Rank] 
        ) 
     + 
        Iif 
        ( 
             ( 
             [Sorted Models].Item([Measures].[Previous Set Index]), 
             [Measures].[Sales Amount] 
             ) 
          = 
             [Measures].[Sales Amount] 
         ,0 
         ,1 
        ) 
End

SELECT
  {
      [Measures].[Sales Amount]
    , [Measures].[Rank]
    , [Measures].[Dense Rank]
    //, [Measures].[Previous Set Index]
  } ON rows
 ,NON EMPTY
     {
     // FILTER Can be used to get the TOP 3 using DENSE RANK 
      FILTER (  
               [Sorted Models]
          , [Measures].[Dense Rank] <=1
          )

     } ON columns
    FROM  [MdCubeTest]
    where [Dim Product Group Item].[Sub Category Name].&[Bag]`