MDX Fillter in Cube

Post Reply
bogdan
Posts: 18
Joined: Wed Oct 15, 2014 9:33 am
OLAP Product: Cognos
Version: 10.2
Excel Version: 2013

MDX Fillter in Cube

Post by bogdan »

Hello, I create an MDX query that filters by the value of the cube, a dimension which we asked, but why it does not work?


This query does not return result

Code: Select all

{Filter ({TM1SUBSETALL( [Model] )}, [cost centers mapping 4].(STRTOMEMBER('[OPEX cost centers].['+[OPEX cost centers].CurrentMember.Name+']'),  [!y22].[Choose]) = "1")}
And here works

Code: Select all

{Filter ({TM1SUBSETALL( [Model] )}, [cost centers mapping 4].(STRTOMEMBER('[OPEX cost centers].['+'206'+']'),  [!y22].[Choose]) = "1")}
Thanks
Headon01
Posts: 6
Joined: Tue Nov 11, 2014 2:34 pm
OLAP Product: TM1, Cognos
Version: 9.5.2
Excel Version: 2010

Re: MDX Fillter in Cube

Post by Headon01 »

Bogdan,

I hope I am reading this correctly but I believe you are trying to filter on a cube that has 3 dimensions ("Model", "OPEX cost centers", "!y22" variable?) and return the corresponding "Model" members. If this is true, you don't need to specify any dimension that uses all the members (in this case "OPEX cost centers"). So, you can use the MDX statement:

Code: Select all

Filter(TM1SUBSETALL( [Model] ), [cost centers mapping 4].([!y22].[Choose]) = "1")
I've also removed all the braces from the MDX statement because if the MDX function returns a set, you don't have to wrap it in the set braces. It won't hurt to leave them in but it makes it harder to read the statement.

Micheal
bogdan
Posts: 18
Joined: Wed Oct 15, 2014 9:33 am
OLAP Product: Cognos
Version: 10.2
Excel Version: 2013

Re: MDX Fillter in Cube

Post by bogdan »

I have cube "Measures" with dimensions ("Model", "OPEX cost centers", 'Business', 'Measures' ... etc) and cube 'Сost centers mapping 4' ("Model", "OPEX cost centers", "!y22")

And that I had to select dimension 'OPEX cost centers' in cube 'Measurs' measurement 'Model' has been filtered items from the cube 'Сost mapping centers 4' on the selected element from the dimension 'OPEX cost centers'.

For example in Cuba 'Сost mapping centers 4' such values.

Opex Cost Centers | Model | !y22
203 | BOO | 1
203 | BAA | 1
203 | CAA | 0
210 | BOO | 0
210 | BAA | 1
210 | CAA | 0

And that would be a value of 203 in the dimension "OPEX cost centers" in Cuba 'Measures' dimension 'Model' we had available values ('BOO', BAA '). And if you select '210' dimension 'Model' we had available values ('BAA ') .

Thanks
blackhawk
Community Contributor
Posts: 136
Joined: Thu May 29, 2008 2:29 pm

Re: MDX Fillter in Cube

Post by blackhawk »

bogdan,

To be able to use CurrentMember it has to have some context for that dimension; which either must be for that dimension you are filtering or via a query to another cube. The MDX you supplied is a dimensional MDX expression not an MDX query. You are also working with [Model] dimension so there is no context of CurrentMember for the OPEX Cost Centers dimension.

Another way to think about it is this: While iterating through the Model dimension, how does your filter statement know which OPEX Cost Center to select and put into the expression?

You are either going to have to put in a cube expression or use a generate statement. I would consider using a cube query rather than a generate because a generate statement can be a performance issue. The cube query, though will have to be fully qualified to work. It is in the form of:

(CubeName).(dim1,dim2,dim3,...)

Hope that helps.
bogdan
Posts: 18
Joined: Wed Oct 15, 2014 9:33 am
OLAP Product: Cognos
Version: 10.2
Excel Version: 2013

Re: MDX Fillter in Cube

Post by bogdan »

blackhawk wrote:bogdan,

To be able to use CurrentMember it has to have some context for that dimension; which either must be for that dimension you are filtering or via a query to another cube. The MDX you supplied is a dimensional MDX expression not an MDX query. You are also working with [Model] dimension so there is no context of CurrentMember for the OPEX Cost Centers dimension.

Another way to think about it is this: While iterating through the Model dimension, how does your filter statement know which OPEX Cost Center to select and put into the expression?

You are either going to have to put in a cube expression or use a generate statement. I would consider using a cube query rather than a generate because a generate statement can be a performance issue. The cube query, though will have to be fully qualified to work. It is in the form of:

(CubeName).(dim1,dim2,dim3,...)

Hope that helps.
You can throw an example of how to implement this task?
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: MDX Fillter in Cube

Post by tomok »

bogdan wrote:You can throw an example of how to implement this task?
This is must reading for anyone first learning MDX....http://www.bihints.com/creating_dynamic ... x_a_primer
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
BariAbdul
Regular Participant
Posts: 424
Joined: Sat Mar 10, 2012 1:03 pm
OLAP Product: IBM TM1, Planning Analytics, P
Version: PAW 2.0.8
Excel Version: 2019

Re: MDX Fillter in Cube

Post by BariAbdul »

This is must reading for anyone first learning MDX....http://www.bihints.com/creating_dynamic ... x_a_primer
Thanks Tomok,This is the updated MDX Primer link:
http://www.pxbconsulting.com/downloads.html :)
"You Never Fail Until You Stop Trying......"
bogdan
Posts: 18
Joined: Wed Oct 15, 2014 9:33 am
OLAP Product: Cognos
Version: 10.2
Excel Version: 2013

Re: MDX Fillter in Cube

Post by bogdan »

BariAbdul wrote:
This is must reading for anyone first learning MDX....http://www.bihints.com/creating_dynamic ... x_a_primer
Thanks Tomok,This is the updated MDX Primer link:
http://www.pxbconsulting.com/downloads.html :)
I read this book. there is no information how to accomplish my task
Post Reply