在Excel中查看测量定义(DAX)

时间:2017-05-18 21:00:23

标签: excel ssas dax ssas-tabular

我是DAX和SSAS-Tabular的新手,所以我希望你能原谅任何无知。
我们有一个SSAS-Tabular多维数据集,我们在Excel中使用它来查看数据(数据透视表)。有没有办法让我在Excel中查看度量背后的DAX?

谢谢,

1 个答案:

答案 0 :(得分:0)

在Excel中,转到“数据”选项卡,单击“新建查询”,选择“从数据库”,从“SQL Server Analysis Services数据库”中选择“。” 输入服务器的名称和数据库的名称(多维数据集的名称) 单击“MDX或DAX查询(可选)”旁边的下拉列表 添加以下查询(请注意,这是DMX,而不是MDX或DAX,但它可以工作 - 请注意,如果您不编辑目录名称以匹配您的多维数据集,它将不会返回任何数据):

SELECT 
    [MEASUREGROUP_NAME] AS  [Table Name],
    [MEASURE_CAPTION]   AS  [Measure Name],
    [DESCRIPTION]       AS  [Measure Description],
    [EXPRESSION]        AS  [Measure Logic]
FROM 
    $SYSTEM.MDSCHEMA_MEASURES
WHERE 
    [CUBE_NAME]  ='Model'
AND
    [MEASURE_IS_VISIBLE]
AND
    [CATALOG_NAME] = '<enter name of your cube here>'
ORDER BY 
    [MEASUREGROUP_NAME]

点击“加载”。
您现在在电子表格中有一个页面,用作度量的数据字典。你可以做同样的事情,用这段代码添加维度的查询:

SELECT 
    [DIMENSION_UNIQUE_NAME] AS  [Table Name],
    HIERARCHY_CAPTION       AS  [Column Name],
    [DESCRIPTION]           AS  [Column Description]
FROM 
    $system.MDSchema_hierarchies
WHERE 
    [CUBE_NAME]  = 'Model'
AND 
    [HIERARCHY_ORIGIN] = 2
AND 
    [HIERARCHY_IS_VISIBLE]
AND
    [CATALOG_NAME] = '<enter name of your cube here>'
ORDER BY 
    [DIMENSION_UNIQUE_NAME]

对于表格,此代码:

SELECT 
    [DIMENSION_CAPTION] AS  [Table Name],
    [DESCRIPTION]       AS  [Table Description]
FROM 
    $system.MDSchema_Dimensions
WHERE 
    [CUBE_NAME]  ='Model'
AND 
    [DIMENSION_CAPTION] <> 'Measures'
AND
    [CATALOG_NAME] = '<enter name of your cube here>'
ORDER BY 
    [DIMENSION_CAPTION]

对于层次结构,此代码:

SELECT 
    [DIMENSION_UNIQUE_NAME] AS  [Table Name],
    [HIERARCHY_CAPTION]     AS  [Hierarchy Name],
    [DESCRIPTION]           AS  [Hierarchy Description]
FROM 
    $system.MDSchema_hierarchies
WHERE 
    [CUBE_NAME]  = 'Model'
AND 
    [HIERARCHY_ORIGIN] = 1
AND
    [CATALOG_NAME] = '<enter name of your cube here>'
ORDER BY 
    [DIMENSION_UNIQUE_NAME]

如果编辑这些查询的属性(使用数据选项卡上的“连接”按钮),则可以在每次打开工作表时将此工作表设置为刷新(类似于您可能已设置数据透视表连接的方式) ),现在您拥有自动反映最新立方体设计的数据字典选项卡。希望这有帮助!