Filter by Attribute

Post Reply
Chuks
Posts: 30
Joined: Wed Dec 05, 2012 2:18 pm
OLAP Product: IBM Cognos Planning Analytics
Version: 2.0
Excel Version: 2010

Filter by Attribute

Post by Chuks »

Hi All,

We have a dimension with some elements and an attribute associated with it,as below

Dim1
A
B
C
Attributes ( in the order of Dimension elements given above)
P1,P2,P3
P2,P4,P5
P5

Now we have a requirement to get all the elements from Dimension Dim, which has P2 in its attribute, so in this example A and B would be the expected result. Could you please let me know if its possible?

Thanks.
Wim Gielis
MVP
Posts: 3113
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Filter by Attribute

Post by Wim Gielis »

For example:

Code: Select all

{FILTER( {TM1SUBSETALL( [Dimension] )}, Instr([Dimension].[Attribute], "P2") > 0 )}
Combine this with function like LCase and UCase because Instr is case-sensitive.
Also, make sure that finding P2 with Instr does not lead to let's say P25, which contains P2.
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Chuks
Posts: 30
Joined: Wed Dec 05, 2012 2:18 pm
OLAP Product: IBM Cognos Planning Analytics
Version: 2.0
Excel Version: 2010

Re: Filter by Attribute

Post by Chuks »

Hi Again,

Thanks Wim, it worked!

I would like to know if there is a possibility to create MDX query which does a filter by attribute on leaf level elements of the dimension and give us the leaf elements which matches the attribute value along with the parent of that leaf element.

Eg:
Dim1
Alpha(parent of below elements)
A
B
C
Attributes ( in the order of Dimension elements given above)
P1,P2,P3
P2,P4,P5
P5

MDX Query: Filter by attribute which has value as P2.

Expected Result:
Alpha
A
B

Thanks!
User avatar
jpm_de
Posts: 22
Joined: Thu Jun 10, 2010 5:19 pm
OLAP Product: TM1
Version: 10.2.2 FP3
Excel Version: 2010

Re: Filter by Attribute

Post by jpm_de »

Hi there,

To start working with TM1's MDX functionality, you should take a look at this document:

Creating Dynamic Subsets in Applix TM1 with MDX - A Primer
http://bihints.com/book/export/html/68

And keep in mind, that you can do a lot of stuff with TM1, so there might be other ways (than the one's in other products) to achieve a task more easily.
Therefore is is of much help to describe the why you want to do something and not just the what your next step might look like.

Best regards,
JP
Why TM1? Because ...with great dimensionality there must also come -- great responsibility!
(http://www.quotecounterquote.com/2012/0 ... great.html)
Chuks
Posts: 30
Joined: Wed Dec 05, 2012 2:18 pm
OLAP Product: IBM Cognos Planning Analytics
Version: 2.0
Excel Version: 2010

Re: Filter by Attribute

Post by Chuks »

Hi JP,

Thanks for the link! It has lot of useful functions listed. But actually I couldn't get any function from there to use for the requirement i stated below,

I would need a subset which displays both leaf and consolidation of that leaf based on the filter on the leaf elements. Please let me know if it can be created using an MDX expression.

Thanks!
jduplessis
Posts: 19
Joined: Tue Sep 16, 2014 11:51 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2010
Location: Ottawa, Canada

Re: Filter by Attribute

Post by jduplessis »

Chuks wrote:Hi JP,

Thanks for the link! It has lot of useful functions listed. But actually I couldn't get any function from there to use for the requirement i stated below,

I would need a subset which displays both leaf and consolidation of that leaf based on the filter on the leaf elements. Please let me know if it can be created using an MDX expression.

Thanks!
You can use a function like generate. If what Wim provided worked for leaves try:

Code: Select all

{GENERATE(
   { FILTER( {TM1SUBSETALL( [Dimension] )}, Instr([Dimension].[Attribute], "P2") > 0 ) },
   { [Dimension].CurrentMember.Parent, [Dimension].CurrentMember }
)}
Not sure this is the best way to do this, sure someone will correct me if its not.
Post Reply