MDX格式结果

时间:2019-04-15 01:31:06

标签: mdx

我是MDX查询的新手。我在更改MDX输出的格式设置时遇到麻烦。我使用“ Adventure Works Internet销售模型”做了一个类似的例子。见下文:

WITH 
  MEMBER [Measures].[Calculate YTD] AS 
    Sum
    (
      periodstodate([Date].[Calendar].[Year],[Date].[Calendar].CurrentMember)
     ,[Measures].[Internet Total Sales]
    ) 
SELECT 
  {[Measures].[Internet Total Sales]

   ,[Measures].[Calculate YTD]

  } ON COLUMNS,
  [Date].[Calendar].[Month] ON ROWS

FROM [Adventure Works Internet Sales Model]

WHERE ([Date].[Date].&[2012-01-01T00:00:00]:[Date].[Date].&[2018-01-01T00:00:00])WHERE ([Date].[Date].&[2012-01-01T00:00:00]:[Date].[Date].&[2018-01-01T00:00:00])

结果如下:

MDX results

我想看到的是“ [Date]。[Calendar]。[Month]”行显示为月底日期(例如,2019年3月31日)

1 个答案:

答案 0 :(得分:0)

欢迎您!

您可以添加一个附加列来显示每月的最后一天:

WITH 
  MEMBER [Measures].[Last Day of Month] AS 
    [Date].[Calendar].CurrentMember.LastChild.MEMBER_CAPTION
  MEMBER [Measures].[Last Day of Month v2] AS 
    TAIL(EXISTING [Date].[Date].[Date].MEMBERS).ITEM(0).ITEM(0).MEMBER_CAPTION
MEMBER [Measures].[Calculate YTD] AS 
    Sum
    (
      periodstodate(
        [Date].[Calendar].[Year],[Date].[Calendar].CurrentMember
      )
     ,[Measures].[Internet Total Sales]
    ) 
SELECT 
  { 
   [Measures].[Last Day of Month]
  , [Measures].[Last Day of Month v2]
   ,[Measures].[Internet Total Sales]
   ,[Measures].[Calculate YTD]
  } ON COLUMNS,
  [Date].[Calendar].[Month] 
  ON ROWS
FROM [Adventure Works Internet Sales Model]
WHERE 
(
 [Date].[Date].&[2012-01-01T00:00:00]:
 [Date].[Date].&[2018-01-01T00:00:00]
);

Output