简体   繁体   English

如何在mdx查询中建立2个度量和层次结构

[英]How to establish in a mdx query 2 measures and a hierarchy

I Have this query: 我有这个查询:

SELECT NON EMPTY {
    [Art].[Art].[Art].ALLMEMBERS * [Measures].[Costs] * [Measures].[Margin]
} ON COLUMNS 
FROM  [Model]  
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE,
    FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

I get an error, stating that this cannot be done. 我收到一条错误消息,指出无法完成此操作。 My idea is to show, for each member, its cost and margin, as follows: 我的想法是为每个成员显示其成本和利润,如下所示:

Article 1     | Article 2     | Article 3
cost | margin | cost | margin | cost | margin 

Which would be the correct way? 哪个是正确的方法? By the way, any good tutorial or website to learn about creating mdx queries? 顺便说一句,有什么好的教程或网站可以学习有关创建mdx查询的信息吗?

Your query is crossjoining the measures together: [Measures].[Costs] * [Measures].[Margin] but your idea for the expected results is different. 您的查询将度量交叉在一起: [Measures].[Costs] * [Measures].[Margin]但您对预期结果的想法不同。 What you show in your expected result is a crossjoin of two sets: {Articles} * {Measures} 您在预期结果中显示的是两组交叉连接: {Articles} * {Measures}

I suggest something more like this: 我建议更像这样:

SELECT 
    {[Measures].[Costs], [Measures].[Margin]} ON COLUMNS,
    NON EMPTY {[Art].[Art].[Art].ALLMEMBERS} ON ROWS 
FROM [Model]  
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Or if you want it all on the columns, like your expected result: 或者,如果您希望所有这些都在列上,例如您的预期结果:

SELECT 
    NON EMPTY {[Art].[Art].[Art].ALLMEMBERS} * 
        {[Measures].[Costs], [Measures].[Margin]} ON COLUMNS
FROM [Model]  
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

For learning about MDX, I recommend the book "MDX Solutions" as a gentle introduction. 为了了解MDX,我建议您将本书“ MDX解决方案”作为简要介绍。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM