简体   繁体   中英

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]

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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