dbTalk Databases Forums  

filter dimension member

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss filter dimension member in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tony
 
Posts: n/a

Default filter dimension member - 04-14-2004 , 12:41 PM






I want to filter dimension member by user input. I have an 'age' dimension, who's members consist of lets say 10, 11, 12, ..., 20, say the user wants only data from ages <= 12, the resulting table should look like

measure1 measure
--------------------------------------------
10 xxxx xxx
11 xxxx xxx
12 xxxx xxx

Is there a way to limit dimension member using the FILTER keyword? If not any suggestions will be greatly appreciated.

Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: filter dimension member - 04-14-2004 , 09:11 PM






If you can construct the MDX from user input, then like:

Quote:
Filter(Age.Years.Members,
StrToValue(Age.CurrentMember.Name) <= 12)
Quote:
- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply With Quote
  #3  
Old   
Tony
 
Posts: n/a

Default Re: filter dimension member - 04-15-2004 , 11:51 AM



Thank you so much. However I can't quite get it to run, I got a syntax error (token is not valid, apparently because of the "All Age" member, any idea on how to get around it?) when using the StrToValue function in the Filter statement

select
{[Measures].[Id]} on columns,
{Filter([age].Members, StrToValue([age].CurrentMember.Name) < 12)} on row
from tes

However I changed StrToValue to VBA!Value and it works like a charm

select
{[Measures].[Id]} on columns,
{Filter([age].Members, VBA!Val([age].CurrentMember.Name) < 12)} on row
from tes

I was under the impression that VBA!Val and StrToValue are equivalent

----- Deepak Puri wrote: ----

If you can construct the MDX from user input, then like

Quote:
Filter(Age.Years.Members
StrToValue(Age.CurrentMember.Name) <= 12


- Deepa

*** Sent via Developersdex http://www.developersdex.com **
Don't just participate in USENET...get rewarded for it



Reply With Quote
  #4  
Old   
Deepak Puri
 
Posts: n/a

Default Re: filter dimension member - 04-15-2004 , 04:03 PM



VBA!Val and StrToValue are not quite equivalent - I don't know all the
differences, but in your case Val() may be evaluating the [All Age]
member name as 0, whereas StrToValue() raises an error, since it is not
numeric.

My suggested MDX: 'Age.Years.Members' lists the members of the "Years"
level of the [Age] dimension (all of which presumably have names that
are numeric strings). This excludes the [All Age] member, whose level is
higher.


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.