如何确定尺寸是否相关?

问题描述

| 我正在开发一个查询生成器应用程序,该应用程序生成MDX并尝试使用以下方法从多维数据集获取客户计数,该方法工作正常:
WITH MEMBER MEASURES.X AS (
    { [Customer].[Gender].[Female]},[Customer].[Customer].Children
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]
但是,如果用户拖动与客户无关的尺寸,例如:
WITH MEMBER MEASURES.X AS (
    { [Customer].[Gender].[Female]},{ [Employee].[Status].[Active],[Employee].[Status].[Inactive]},[Customer].[Customer].Children
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]
计数结果显然变得不正确。 有没有一种方法可以确定某个维度是否与客户相关,以便可以将其从生成的MDX查询中排除?     

解决方法

        可以通过AMO从多维数据集中检索此信息。
Cube
类包含您需要的所有多维数据集元数据。     ,        通过使用Exists(Set_Expression1,Set_Expression2 [,MeasureGroupName])函数解决了该问题。无需手动确定相关的尺寸。 Exists功能过滤掉不相关的元组,仅保留 设置
{ [Customer].[Customer].Children,[Customer].[Gender].[Female]}
进行计数。 这是MDX:
WITH MEMBER MEASURES.X AS Exists(
    [Customer].[Customer].Children,{[Customer].[Gender].[Female]}
    *
    {[Employee].[Status].[Active],[Employee].[Status].[Inactive]}
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...