MDX - icCube - How to get a DYNAMIC topcount/toppercent with other aggregated?

会有一股神秘感。 提交于 2019-12-10 19:14:17

问题


Using the following mdx, I'm able to retrieve correct data dynamically.

create CATEGORY MEMBER [Stats].[Top].[All Etabs].[Top 5 Etablissements] 
    as topcount( [Etablissement].[Etablissement].[Etablissement].allMEMBERS, 5, [Measures].[Nbsejours]),ADD_CHILDREN=true

create CATEGORY MEMBER [Stats].[Top].[All Etabs].[Autres Etablissements (>5)] 
    as Except([Etablissement].[Etablissement].[Etablissement].members,  TopCount( [Etablissement].[Etablissement].[Etablissement].MEMBERS, 5, [Measures].[Nbsejours])),ADD_CHILDREN=false

create dynamic set [Top 5 & Others] 
    as {[Stats].[Top].[Top 5 Etablissements], [Stats].[Top].[Autres Etablissements (>5)]}

Select {[Measures].[NbSejours]} on 0,
nonempty ([Top 5 & Others]) on 1
From //[Cube]
( SELECT { {[Geographique].[Zone].[All-M].&[1006]} } ON 0 FROM [Cube])

But, the topCount is not dynamic itself. In this example, the top 5 etablissement never change, only the values do change...

Is there a way to get this with dynamic topCount/topPercent ? Txs, Bertrand.


回答1:


Categories (*) have not yet the dynamic flag so it's not possible to define a category that will be calculated for each MDX request once as it happens for a set.

So it's going to be something more like (note I've use the SubCubeComplement that is a lot - may be really a lot - faster )

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
SELECT
  {[Measures].[NbSejours]} on 0,
  { [Stats].[Top].[Top 5 Etablissements], 
    [Stats].[Top].[Autres Etablissements (>5)] } on 1
From [Cube]

(*) For the people that are not used to icCube, Categories is a way defining a 'new' member as a set of members (they might have different dimensionalities). This ensures for complex calculations, schemas with many-to-many relations that the values are correctly calculated. Otherwise it might be a little nightmare to ensure calculation correctness.



来源:https://stackoverflow.com/questions/28044671/mdx-iccube-how-to-get-a-dynamic-topcount-toppercent-with-other-aggregated

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!