SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Dynamic Filtering based on Member properties


Dynamic Filtering based on Member properties

Author
Message
Jason-299789
Jason-299789
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2081 Visits: 3232
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
Nevyn
Nevyn
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1512 Visits: 3149
Perhaps a .Item(0) after the filter?
Jason-299789
Jason-299789
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2081 Visits: 3232
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
Nevyn
Nevyn
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1512 Visits: 3149
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search