简体   繁体   English

MDX-icCube-如何使用类别获取前x占总数的百分比

[英]MDX - icCube - How to get a percentage of the Top x on the total using Categories

Following the post on dynamic topcount/toppercentage (see here ) I am looking for an additional row of information showing the % of the Top X in relation to the Total. 在有关动态最高计数/最高百分比的帖子(请参阅此处 )之后,我正在寻找另一行信息,以显示前X相对于总数的百分比。

So, something like 所以,像

  create dynamic set [Top 5] as 
      topcount( [Etablissement].[Etablissement].[Etablissement].members, 5, [Measures].[Nbsejours])

*** End script ***

WITH 
 CATEGORY HIERARCHY [Stats].[Top], DEFAULT_MEMBER_NAME = "All Etabs"
 CATEGORY MEMBER [Stats].[Top].[All Etabs].[Top 5 Etablissements] as 
      [Top 5],ADD_CHILDREN=true
 CATEGORY MEMBER [Stats].[Top].[All Etabs].[Autres Etablissements (>5)] as
      SubCubeComplement([Top 5]),ADD_CHILDREN=false

/* This is what I try, but it does not work */
CATEGORY MEMBER [Stats].[Top].[All Etabs].[Top 5 is % of total] as
      [Top 5]/ [Etablissement].[Etablissement].[Etablissement].members, ADD_CHILDREN=false

SELECT
  {[Measures].[NbSejours]} on 0,
  { [Stats].[Top].[Top 5 Etablissements], 
    [Stats].[Top].[Autres Etablissements (>5)],
    [Stats].[Top].[Top 5 is % of total] } on 1
From [Cube]

Unfortunately, I get the error "the tuple expression did not generate a set of tuples or a sub-cube (numeric)." 不幸的是,我收到错误消息“元组表达式未生成一组元组或一个子多维数据集(数字)。”

Is such a thing possible, and how? 这样的事情有可能吗?

The suggestion in the comments above to add a calculated member in another 'not used' dimension worked: 上面评论中的建议在另一个“未使用”维度中添加计算所得成员的建议有效:

     WITH 
     CATEGORY HIERARCHY [Stats].[Top], DEFAULT_MEMBER_NAME = "All Etabs"
     CATEGORY MEMBER [Stats].[Top].[All Etabs].[Top 5 Etablissements] as 
          [Top 5],ADD_CHILDREN=true
     CATEGORY MEMBER [Stats].[Top].[All Etabs].[Autres Etablissements (>5)] as
          SubCubeComplement([Top 5]),ADD_CHILDREN=false
    /* the hierarchy [Stats].[stats] exists, I add a new calculated member
       to it */
    CALCULATED MEMBER [Stats].[Stats].[Top 5 is % of total] as
         [Stats].[Top],[Stats].[Top].[All Etabs]
    SELECT
      {[Measures].[NbSejours]} on 0,
      {([Stats].[Stats].[default] /* the default member */}* { [Stats].[Top].[Top 5 Etablissements], 
        [Stats].[Top].[Autres Etablissements (>5)],
        [Stats].[Top].[Top 5 is % of total] }) 
      +({[Stats].[Stats].[Top 5 is % of total]} * {[Stats].[Top],[Stats].[Top].[All Etabs]}) on 1
    From [Cube]

The only drawback is that I now get a column in addition. 唯一的缺点是我现在还获得了一个专栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows窗体C#中形成的动态mdx查询中的转义百分比字符(%) - Escape percentage character (%) in a dynamic mdx query formed in windows forms C# 如何获取动态创建的文本框的 id 和总值? - How I get id and total value of dynamically created text boxes? 如何为计算所得成员建立动态MDX公式? - How to build a dynamic MDX formula for a calculated member? Excel-动态图表x轴-忽略没有数据的x类别 - Excel - dynamic chart x axis - ignore x categories with no data MDX 从 2 年前开始销售到今天 - MDX Get Sales starting from 2 years ago to today 如何制作带有类别的动态菜单 - How to make dynamic menu with categories 如何动态获取Pig组中的前N个百分比记录 - How to dynamically get Top N percent records within group in Pig find 使用 1,5,10,25,50 cents 获得总计 17cents 的方法数(例如) - find Number of ways to get total of 17cents (for example) using 1,5,10,25,50 cents SQL生成一个包含多个前X个记录的表,其中top#来自另一个表 - SQL Generate a table of multiple top X records, where top # comes from another table 如何使用坐标显示带有许多按钮的图像; 左,上,右和下 - How to display an image with many buttons by using coordinates; left,top,right and bottom
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM