[英]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.