MDX结果分类

发布于 2024-10-02 22:26:52 字数 1310 浏览 4 评论 0原文

我是 mdx 的新手,现在已经尝试解决以下问题大约一天了。任何帮助将不胜感激:

我的查询:

select {[Measures].[Kunden]} ON COLUMNS,
NON EMPTY Hierarchize(Union({CurrentDateMember([dimZeit], "[\di\mZeit] 
\.[yyyy]"), CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]").Children}, 
CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]\.[q]").Children))) ON ROWS
FROM Center

它给出了以下结果,如预期:

Zeit        Kunden
2010        1561
 - Q1       523
 - Q2       470
 - Q3       256
 - Q4       312
  - Nov.    312

现在,我想要实现的是将列“Kunden”拆分为列“Kunden <” 5分钟'和'Kunden> 5min’指等待时间少于或超过5分钟的顾客。

我能得到的最接近结果如下:

WITH 
MEMBER [Measures].[LT5] AS 
Aggregate(
Filter([Measures].[Kunden], [Measures].[Wartezeit] < 3000))
select {[Measures].[LT5]} ON COLUMNS,
NON EMPTY Hierarchize(Union({CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]"), 
CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]").Children}, 
CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]\.[q]").Children)) ON ROWS
FROM Center

结果是:

Zeit        Kunden
2010        -
 - Q1       75
 - Q2       23
 - Q3       86
 - Q4       71
  - Nov.    71

我理解其原因是,因为 2010 年全年的合计 [Measure].[Wartezeit] 超过 3000 秒。但我希望看到等待时间低于 3000 秒的客户数量,因此 2010 年应该是 75+23+86+71 = 255。

I'm new to mdx and have been trying to solve the following problem for about a day now. Any help would be appreciated:

My Query:

select {[Measures].[Kunden]} ON COLUMNS,
NON EMPTY Hierarchize(Union({CurrentDateMember([dimZeit], "[\di\mZeit] 
\.[yyyy]"), CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]").Children}, 
CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]\.[q]").Children))) ON ROWS
FROM Center

which gives the following result, as expected:

Zeit        Kunden
2010        1561
 - Q1       523
 - Q2       470
 - Q3       256
 - Q4       312
  - Nov.    312

Now, what I want to achieve is to split the column 'Kunden' into columns 'Kunden < 5 min' and 'Kunden > 5min' which means customers who have waited for less or more than 5 minutes.

The closest I could get was the following:

WITH 
MEMBER [Measures].[LT5] AS 
Aggregate(
Filter([Measures].[Kunden], [Measures].[Wartezeit] < 3000))
select {[Measures].[LT5]} ON COLUMNS,
NON EMPTY Hierarchize(Union({CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]"), 
CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]").Children}, 
CurrentDateMember([dimZeit], "[\di\mZeit]\.[yyyy]\.[q]").Children)) ON ROWS
FROM Center

The result is:

Zeit        Kunden
2010        -
 - Q1       75
 - Q2       23
 - Q3       86
 - Q4       71
  - Nov.    71

I understand the cause for this is, because the aggregated [Measure].[Wartezeit] for the whole year 2010 is above 3000 seconds. But I'd like to see the amount of customers with a waiting time below 3000 seconds, so it should be 75+23+86+71 = 255 for 2010.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁的年少不轻狂 2024-10-09 22:26:52

通过在 wartezeit 列上创建一个退化维度来解决这个问题,在 mondrian 中如下所示:

<Dimension name="dauer">
  <Hierarchy hasAll="true">
    <Level name="dauer" column="dauer" uniqueMembers="true">
      <KeyExpression>
        <SQL dialect="generic"> 
           <![CDATA[(case when dauer < 300 then 'LT5' 
                          when dauer < 600 then 'LT10'
                          else 'GT60'
                     end)]]></SQL>
      </KeyExpression>
    </Level>
  </Hierarchy>
</Dimension>

我的查询的 select 子句现在是一个简单的交叉联接:

({[Measures].[Kunden]} * {[dauer].[LT5], [dauer].[LT10], [dauer].[GT60]}) 

Solved it by creating a degenerated dimension on the wartezeit column that looks like this in mondrian:

<Dimension name="dauer">
  <Hierarchy hasAll="true">
    <Level name="dauer" column="dauer" uniqueMembers="true">
      <KeyExpression>
        <SQL dialect="generic"> 
           <![CDATA[(case when dauer < 300 then 'LT5' 
                          when dauer < 600 then 'LT10'
                          else 'GT60'
                     end)]]></SQL>
      </KeyExpression>
    </Level>
  </Hierarchy>
</Dimension>

The select clause of my query is now a simple crossjoin:

({[Measures].[Kunden]} * {[dauer].[LT5], [dauer].[LT10], [dauer].[GT60]}) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文