简体   繁体   English

在时间层次结构中具有两种度量的计算所得成员的MDX

[英]MDX for calculated member with two measures over time hierarchy

I have a cube with two measures, say Measure A and Measure B. I need to create a single measure say C, from these two based on the business rule at any level of the hierarchy, 我有一个包含两个度量的多维数据集,例如度量A和度量B。我需要根据层次结构中任何级别的业务规则从这两个度量中创建一个度量C。

  1. If A is not empty at the current level (has value for all children at that level), then just aggregate A. Else, aggregate A wherever it is present and aggregate B wherever A is not present and then sum both to make C. 如果A在当前级别上不为空(在该级别上具有所有子代的值),则仅对A进行汇总。否则,对存在的A进行汇总,对不存在的B进行汇总B,然后将两者相加得出C。

It goes like this 像这样

Quarter    Month    A    B
Q1         Apr      2    3
Q1         May           4
Q1         Jun           4

C should be 10 at Quarter level. C在四分之一级别应为10。 Also, 2 for Apr, 4 for May and 4 for Jun [Month level] 另外,4月2日,5月4日和6月4日[月度]

I used the following MDX which works fine at Month level. 我使用了以下MDX,它在月度级别上可以正常工作。

IIF(IsEmpty([Measures].[A]), [Measures].[B], [Measures].[A])

But, at quarter level it just gives me 2 instead of 10 which I now know why :) Any pointers on building a MDX to make it work at any level 但是,在四分之一级别上,它只给了我2个而不是10个,我现在知道为什么:)建立MDX以使其在任何级别上工作的任何指针

[Year - Semester - Quarter - Month] (Granularity is at Month level only)

will be helpful. 会有所帮助。 Thanks :) 谢谢 :)

You can use this Mdx 您可以使用此Mdx

Sum(
   Descendants('current member on your time hierarchy', 'month level'),
   CoalesceEmpty([Measures].[A], [Measures].[B])
)

CoalesceEmpty([Measures].[A], [Measures].[B]) is equivalent to IIf(IsEmpty([Measures].[A]), [Measures].[B], [Measures].[A]) CoalesceEmpty([Measures].[A], [Measures].[B])等同于IIf(IsEmpty([Measures].[A]), [Measures].[B], [Measures].[A])

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

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