简体   繁体   English

如何在MDX中过滤度量

[英]How to filter measures in MDX

I need to filter the measure values as 我需要将度量值过滤为

MeasureA   MeasureB
 10          10
 15          15
  5          20
 20          20

Here I need to get only the measures are not equal, I am using filter function as but not working 在这里我只需要得到的措施不相等,我使用的是过滤功能但不起作用

Select Filter({[Measures].[A], [Measures].[B]}, ([Measures].[A]- [Measures].[B])=0) on 0 from [Cube] 选择过滤器({[Measures]。[A],[Measures]。[B]},([Measures]。[A] - [Measures]。[B])= 0)来自[Cube]的0

Expected result set 预期结果集

    MeasureA   MeasureB     
     5          20

What am I missing? 我错过了什么?

Try using a dimension instead of your measures for the first part of the filter statement. 尝试在过滤器语句的第一部分使用维度而不是度量。 Assuming you are querying products then your query might look like: 假设您正在查询产品,那么您的查询可能如下所示:

select {[Measures].[A],[Measures].[B]} on columns,
filter ({[Products].Members},[Measures].[A] = [Measures].[B]) on rows
from [Sales Cube]

You might want to try creating a calculated field in the DSV for this Fact table... 您可能想尝试在此事实表的DSV中创建计算字段...

CASE
  WHEN MeasureFieldA != MeasureFieldB THEN 1
  ELSE 0
END

Then you can create a "fact dimension" and have this calculated field as an attribute to be used in your queries or calculated measures. 然后,您可以创建“事实维度”,并将此计算字段作为要在查询或计算度量中使用的属性。

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

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