从MDX中的Crossjoin连接字符串

时间:2012-02-06 23:45:48

标签: mdx

SELECT 
NON EMPTY {[Measures].[Page Views]} ON COLUMNS,
NON EMPTY {
    Crossjoin({[Date Dim.Weekday Hierarchy].[Weekday].Members}, 
              {[Time Dimension.Time Hierarchy].[Hour].Members})
          } ON ROWS
FROM [All Facts]

是每个工作日获取网页浏览量的代码。它目前返回如下数据:

  

星期日
  ...... 0 - 198273
  ...... 1 - 123987
  ...... 2 - 128372
  ...... 3 - 1283712

每天每小时

。 如何让它连接交叉连接中的字符串,以便返回:

  

周日0 - 198273
  星期日1 - 123987
  星期日2 - 128372
  周日3 - 1283712

或者必须将其创建为一种全新的措施吗?

2 个答案:

答案 0 :(得分:2)

抱歉,我有点不着急,但您可以使用mdx calculated members生成字符串:

 With
  Member MyOutput AS [Date Dim.Weekday Hierarchy].[Weekday].name + " " + [Time Dimension.Time Hierarchy].[Hour] + " " + STR( ([Measures].[Page Views]) )
 SELECT 
  NON EMPTY {[Measures].[MyOutput]} ON COLUMNS,
  NON EMPTY {
    Crossjoin({[Date Dim.Weekday Hierarchy].[Weekday].Members}, 
          {[Time Dimension.Time Hierarchy].[Hour].Members})
      } ON ROWS
  FROM [All Facts]

答案 1 :(得分:0)

找到解决方案:

> WITH MEMBER [Measures].[pretty hour] AS [Date Dim.Weekday Hierarchy].[Weekday].CurrentMember.name || " " || [Time Dimension.Time Hierarchy].[Hour].CurrentMember.name 
>   SELECT    
>   NON EMPTY {[Measures].[pretty hour], [Measures].[Page Views]} ON COLUMNS,   
>   NON EMPTY {    
>       Crossjoin({[Date Dim.Weekday Hierarchy].[Weekday].Members},     
>                 {[Time Dimension.Time Hierarchy].[Hour].Members})   
>             } ON ROWS   
>FROM [All Facts]

你必须忽略行标题,但它会产生我想要的结果! :) @icCube有正确的想法,只需蒙德里安需要||而不是+,和“CurrentMember.name”而不仅仅是“名称”