简体   繁体   中英

Filter member properties in Query Designer using MDX

How can I filter two member properties using MDX?

在此输入图像描述

Currently I have the following solution. It works but I'm sure an MDX query would be much more efficient.

The Dataset in Query Designer has the following MDX to include the member properties as fields:

DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME, [Store].[Store].[Closed Date],[Store].[Store].[Opening Date]

I am using two filters in the Dataset Properties with the following expressions:

    =Cint(Fields!Opening_Date.Value) 
    < 
    =Cint(Format(Today(), "yyyyMMdd"))

and

    =Cint(Fields!Closed_Date.Value) 
    >
    =Cint(Format(Today(), "yyyyMMdd"))

I doubt performance of the below would be satisfactory, but you can give it a shot.

SELECT SomeDim.SomeHIerarchy.MEMBER 
HAVING 
Val(SomeDim.SomeHIerarchy.CURRENTMEMBER.Properties("Opening Date")) <  Format(now(), "dd-MM-yyyy")
Val(SomeDim.SomeHIerarchy.CURRENTMEMBER.Properties("Closing Date")) > Format(now(), "dd-MM-yyyy")
ON 1,
Measures.Foo on 0
FROM [Your Cube]

I found that using a filter was the best way to solve this:

filter(
  [Store].[Store].members, [Store].[Store].Properties( "Opening Date" ) < Format(Now(),'yyyyMMdd') 
  and [Store].[Store].Properties( "Closed Date" ) > Format(Now(),'yyyyMMdd'))
)

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