Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Dynamic Filtering based on Member properties Expand / Collapse
Author
Message
Posted Thursday, May 15, 2014 9:06 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, October 3, 2014 9:25 AM
Points: 895, Visits: 2,432
I've not done any serious MDX for about 18 months and this is starting to bug me.

I want to create a YTD set, based on a Period setting.

The Period dimension is All->Year->Qtr->Month, and has a member property on the Month that denotes the current period.

In SSMS if I Run the Query

Select 

FILTER
(
[Period].[Yr - Qtr - Mth].[Period].Members
,[Period].[Period].Properties("Is Current Period")
) ON ROWS, NULL ON COLUMNS
FROM
[CUBE]


I get the correct result of 201405.

However when place the FILTER in to the following into a CREATE MEMBER

CREATE MEMBER CURRENTCUBE.[Measures].[YTD Measure]
AGGREGATE
(
YTD
(
FILTER
(
[Period].[Yr - Qtr - Mth].[Period].Members
,[Period].[Period].Properties("Is Current Period")
)
)
,[Measures].[aMeasure]
)

I get a #Value, however If I switch the Filter in the YTD to

STRTOMEMBER("[Period].[Yr - Qtr - Mth].[Period].["+FORMAT(NOW(),"yyyy")+FORMAT(NOW(),"MM")+"]")

It works. The issue with this method is that the Current period doesn't 'switch' on the first of the month, and can be 2-3 days later once the source data has been signed off.


_________________________________________________________________________
SSC Guide to Posting and Best Practices
Post #1571369
Posted Tuesday, May 20, 2014 7:57 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Today @ 7:45 AM
Points: 629, Visits: 2,132
Perhaps a .Item(0) after the filter?
Post #1572680
Posted Wednesday, May 21, 2014 6:40 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, October 3, 2014 9:25 AM
Points: 895, Visits: 2,432
Nevyn (5/20/2014)
Perhaps a .Item(0) after the filter?


Thanks that works a treat though I had to use Item(0).Name, and wrap it all in a StrToMember

The last issue is that it degrades the performance.

I think the option is to create a dynamic/static set and then reference that.


_________________________________________________________________________
SSC Guide to Posting and Best Practices
Post #1573127
Posted Wednesday, May 21, 2014 8:41 AM This worked for the OP Answer marked as solution
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Today @ 7:45 AM
Points: 629, Visits: 2,132
Actually it may be .Item(0).Item(0).

You are trying to get from the set that filter returns down to a member which YTD expects, even though the set has only one member. So you go set to tuple and tuple to member.

Hopefully its just the strtomember stuff that is degrading performance.
Post #1573216
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse