[英]MDX calculated member dimension context
I have the following calculated member which represents the quantity of "overstocked" products: 我有以下计算成员,代表“积压”产品的数量:
WITH
MEMBER [Measures].[Overstocked Items Count] AS
FILTER(
[Items].[Item No].CHILDREN,
[Measures].[Overstocked Qty] > 0
).COUNT
It works just fine for any linked to the measure group dimension except for the Items dimension itself and the reasons are obvious. 它适用于任何链接到度量值组的维度,除了Items维度本身,原因很明显。 Is there a way to create a calculated member that would respect the context it is evaluated in? 有没有办法创建一个计算成员,尊重它所评估的上下文? So basically if this member is evaluated against an item group code I need items count by those groups, not the entire items set. 所以基本上如果根据项目组代码评估此成员,我需要按这些组计算项目,而不是整个项目集。
EXISTING
is a useful keyword that can add the current context to your measure: EXISTING
是一个有用的关键字,可以将当前上下文添加到度量中:
WITH
MEMBER [Measures].[Overstocked Items Count] AS
FILTER(
EXISTING([Items].[Item No].CHILDREN),
[Measures].[Overstocked Qty] > 0
).COUNT
EXISTING
is very good when you want to know the members present from a different hierarchy within the same dimension . 当您想要了解同一维度内不同层次结构中的成员时, EXISTING
非常好。 eg say you have USA selected from the country hierarchy (in geography dimension) and you need to count state/county members from a stateCounty hierarchy that is also part of the geography dimension then EXISTING
is the correct choice. 例如,假设您从国家层级(地理维度)中选择了美国,并且您需要从stateCounty层次结构中计算州/县成员,这也是地理维度的一部分,那么EXISTING
是正确的选择。
If you want to go across dimensions so say you have USA selected and you'd like to count customer, from the customer dimension who are associated with the USA then I don't think EXISTING
will work - you'll need to explore either EXISTS
or NONEMPTY
. 如果你想跨越维度,那么说你选择了美国,并且你想要计算客户,从与美国相关联的客户维度,那么我认为EXISTING
不会工作 - 你需要探索任何一个EXISTS
或NONEMPTY
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.