dbTalk Databases Forums  

MDX: How to filter dimension by member attribute

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


Discuss MDX: How to filter dimension by member attribute in the microsoft.public.sqlserver.olap forum.



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

Default MDX: How to filter dimension by member attribute - 08-18-2005 , 10:27 AM






Hi,
I am just started to work with MDX. I have to dimesion 'Funds' . More
then one 'fund' from "Funds' dimension could have the same 'SubAsset Class'
property. I need to make a set with members from 'Funds' which have the same
'SubAsset Class' property. How should I do it ? I would appreciate any help.


Reply With Quote
  #2  
Old   
Milind
 
Posts: n/a

Default Re: MDX: How to filter dimension by member attribute - 08-18-2005 , 01:03 PM






Try this

SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,
AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = "25")) ON ROWS
FROM FundCube

You can define this in a calculated member if you want

Hope this help

Milind


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

Default Re: MDX: How to filter dimension by member attribute - 08-18-2005 , 01:30 PM



Thank you Milind, but my problem is that I do not know value of :SubAsset
Class" in advance, it dependes on CurrentMember property.

"Milind" wrote:

Quote:
Try this

SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,
AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = "25")) ON ROWS
FROM FundCube

You can define this in a calculated member if you want

Hope this help

Milind



Reply With Quote
  #4  
Old   
martinbx
 
Posts: n/a

Default Re: MDX: How to filter dimension by member attribute - 08-19-2005 , 08:00 AM



Hi,
I am trying to do something like this

set [CurrentFund] as
'{[Fund].currentMember}'

member [Measures].[CurrentFund ID] as
' CLng([CurrentFund].Item(0).Item(0).Properties("SubAsset Class"))'

member [Measures].[FundSiblings]
' CStr
(
Filter
(
Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER),
CLng([Fund].CurrentMember.Properties("SubAsset Class")=
[Measures].[CurrentFund ID]
).Count
)

but I made an error somewhere, sinceMDX can not find properties in my set,
but does not have any problem when it dealing with 'CurrentMember' not packed
in the set.
So I am looking for way to get sutset of [Fund] which has only 'funds' with
exactly the same 'subasset class' as 'CurrentMember'

"Jéjé" wrote:

Quote:
do you mean that you don't know the "25" value?

"it dependes on CurrentMember property." the currentmember of which
dimension?

do you want something like:
SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = <filtering
dimension>.currentmember.property("SubAsset Class Target"))) ON ROWS
FROM FundCube

and the <filtering dimension> contains the list of possibile values to be
used has the target of the filter.


"martinbx" <martinbx (AT) discussions (DOT) microsoft.com> wrote in message
news:7C971CFF-99D0-402C-991F-8A052AD99B5B (AT) microsoft (DOT) com...
Thank you Milind, but my problem is that I do not know value of :SubAsset
Class" in advance, it dependes on CurrentMember property.

"Milind" wrote:

Try this

SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,
AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = "25")) ON ROWS
FROM FundCube

You can define this in a calculated member if you want

Hope this help

Milind





Reply With Quote
  #5  
Old   
Brian Altmann
 
Posts: n/a

Default Re: MDX: How to filter dimension by member attribute - 08-19-2005 , 01:25 PM



Using the Foodmart dimension Store instead of Funds, and the property "Store
Manager" instead of "SubAsset Class"), is this what you mean? (see Johnson in
query results):

with
member measures.Manager as '[store].currentmember.properties("Store Manager")'
member measures.TotalManager as 'sum( generate ( {[store].currentmember}
as curstor , filter( [store name].members ,
curstor.current.properties("Store Manager") =
[Store].currentmember.properties("Store Manager"))) ,[unit sales] )'
select
{Manager, [unit sales] ,[TotalManager] } on columns,
[Store Name].members on rows
from sales

HTH,
--
Brian Altmann
BI Specialist
Huddle Group S.A (www.huddle.com.ar)
www.geocities.com/brianaltmann/olap.html


"martinbx" wrote:

Quote:
Hi,
I am trying to do something like this

set [CurrentFund] as
'{[Fund].currentMember}'

member [Measures].[CurrentFund ID] as
' CLng([CurrentFund].Item(0).Item(0).Properties("SubAsset Class"))'

member [Measures].[FundSiblings]
' CStr
(
Filter
(
Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER),
CLng([Fund].CurrentMember.Properties("SubAsset Class")=
[Measures].[CurrentFund ID]
).Count
)

but I made an error somewhere, sinceMDX can not find properties in my set,
but does not have any problem when it dealing with 'CurrentMember' not packed
in the set.
So I am looking for way to get sutset of [Fund] which has only 'funds' with
exactly the same 'subasset class' as 'CurrentMember'

"Jéjé" wrote:

do you mean that you don't know the "25" value?

"it dependes on CurrentMember property." the currentmember of which
dimension?

do you want something like:
SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = <filtering
dimension>.currentmember.property("SubAsset Class Target"))) ON ROWS
FROM FundCube

and the <filtering dimension> contains the list of possibile values to be
used has the target of the filter.


"martinbx" <martinbx (AT) discussions (DOT) microsoft.com> wrote in message
news:7C971CFF-99D0-402C-991F-8A052AD99B5B (AT) microsoft (DOT) com...
Thank you Milind, but my problem is that I do not know value of :SubAsset
Class" in advance, it dependes on CurrentMember property.

"Milind" wrote:

Try this

SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,
AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = "25")) ON ROWS
FROM FundCube

You can define this in a calculated member if you want

Hope this help

Milind





Reply With Quote
  #6  
Old   
martinbx
 
Posts: n/a

Default Re: MDX: How to filter dimension by member attribute - 08-19-2005 , 03:16 PM



Thanks for advice Brian. Unfortunatly somebody rase "foodmart2000" database
from our server, so I have to try on our code. So I wrote:

'Count
(
Generate(
{[Portfolio Hierarchies].CurrentMember} as CurrMember,
Filter(
[Portfolio Hierarchies].Members,
[Portfolio Hierarchies].CurrentMember.Properties("Portfolio Id")=
CurrMember.Current.Properties("Portfolio Id")
)
)
)'

I got back an error: "Formula error - property name is not valid: "Portfolio
Id" - an error occuerred during attempt to get a cell value", but if I try
directly to output
[Portfolio Hierarchies].CurrentMember.Properties("Portfolio Id") , I get
back valid answer.
I would appreciate any suggestion on what is going on and how to
fix it.

"Brian Altmann" wrote:

Quote:
Using the Foodmart dimension Store instead of Funds, and the property "Store
Manager" instead of "SubAsset Class"), is this what you mean? (see Johnson in
query results):

with
member measures.Manager as '[store].currentmember.properties("Store Manager")'
member measures.TotalManager as 'sum( generate ( {[store].currentmember}
as curstor , filter( [store name].members ,
curstor.current.properties("Store Manager") =
[Store].currentmember.properties("Store Manager"))) ,[unit sales] )'
select
{Manager, [unit sales] ,[TotalManager] } on columns,
[Store Name].members on rows
from sales

HTH,
--
Brian Altmann
BI Specialist
Huddle Group S.A (www.huddle.com.ar)
www.geocities.com/brianaltmann/olap.html


"martinbx" wrote:

Hi,
I am trying to do something like this

set [CurrentFund] as
'{[Fund].currentMember}'

member [Measures].[CurrentFund ID] as
' CLng([CurrentFund].Item(0).Item(0).Properties("SubAsset Class"))'

member [Measures].[FundSiblings]
' CStr
(
Filter
(
Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER),
CLng([Fund].CurrentMember.Properties("SubAsset Class")=
[Measures].[CurrentFund ID]
).Count
)

but I made an error somewhere, sinceMDX can not find properties in my set,
but does not have any problem when it dealing with 'CurrentMember' not packed
in the set.
So I am looking for way to get sutset of [Fund] which has only 'funds' with
exactly the same 'subasset class' as 'CurrentMember'

"Jéjé" wrote:

do you mean that you don't know the "25" value?

"it dependes on CurrentMember property." the currentmember of which
dimension?

do you want something like:
SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = <filtering
dimension>.currentmember.property("SubAsset Class Target"))) ON ROWS
FROM FundCube

and the <filtering dimension> contains the list of possibile values to be
used has the target of the filter.


"martinbx" <martinbx (AT) discussions (DOT) microsoft.com> wrote in message
news:7C971CFF-99D0-402C-991F-8A052AD99B5B (AT) microsoft (DOT) com...
Thank you Milind, but my problem is that I do not know value of :SubAsset
Class" in advance, it dependes on CurrentMember property.

"Milind" wrote:

Try this

SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,
AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = "25")) ON ROWS
FROM FundCube

You can define this in a calculated member if you want

Hope this help

Milind





Reply With Quote
  #7  
Old   
Brian Altmann
 
Posts: n/a

Default Re: MDX: How to filter dimension by member attribute - 08-19-2005 , 03:45 PM



If your dimension name is [Portfolio Hierarchies] then you should replace it
by the Leaf level name as shown here:

Quote:
'Count
(
Generate(
{[Portfolio Hierarchies].CurrentMember} as CurrMember,
Filter(
*** Portfolio Hierarchies Leaf Level Name***.Members,
[Portfolio Hierarchies].CurrentMember.Properties("Portfolio Id")=
CurrMember.Current.Properties("Portfolio Id")
)
)
)'
A member property is only valid for the level at which it is defined, so you
have use [Dimension Level].members. If you [Dimension].members you get the
error you have reported.
HTH,
--
Brian Altmann
BI Specialist
Huddle Group S.A (www.huddle.com.ar)
www.geocities.com/brianaltmann/olap.html


"martinbx" wrote:

Quote:
Thanks for advice Brian. Unfortunatly somebody rase "foodmart2000" database
from our server, so I have to try on our code. So I wrote:

'Count
(
Generate(
{[Portfolio Hierarchies].CurrentMember} as CurrMember,
Filter(
[Portfolio Hierarchies].Members,
[Portfolio Hierarchies].CurrentMember.Properties("Portfolio Id")=
CurrMember.Current.Properties("Portfolio Id")
)
)
)'

I got back an error: "Formula error - property name is not valid: "Portfolio
Id" - an error occuerred during attempt to get a cell value", but if I try
directly to output
[Portfolio Hierarchies].CurrentMember.Properties("Portfolio Id") , I get
back valid answer.
I would appreciate any suggestion on what is going on and how to
fix it.

"Brian Altmann" wrote:

Using the Foodmart dimension Store instead of Funds, and the property "Store
Manager" instead of "SubAsset Class"), is this what you mean? (see Johnson in
query results):

with
member measures.Manager as '[store].currentmember.properties("Store Manager")'
member measures.TotalManager as 'sum( generate ( {[store].currentmember}
as curstor , filter( [store name].members ,
curstor.current.properties("Store Manager") =
[Store].currentmember.properties("Store Manager"))) ,[unit sales] )'
select
{Manager, [unit sales] ,[TotalManager] } on columns,
[Store Name].members on rows
from sales

HTH,
--
Brian Altmann
BI Specialist
Huddle Group S.A (www.huddle.com.ar)
www.geocities.com/brianaltmann/olap.html


"martinbx" wrote:

Hi,
I am trying to do something like this

set [CurrentFund] as
'{[Fund].currentMember}'

member [Measures].[CurrentFund ID] as
' CLng([CurrentFund].Item(0).Item(0).Properties("SubAsset Class"))'

member [Measures].[FundSiblings]
' CStr
(
Filter
(
Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER),
CLng([Fund].CurrentMember.Properties("SubAsset Class")=
[Measures].[CurrentFund ID]
).Count
)

but I made an error somewhere, sinceMDX can not find properties in my set,
but does not have any problem when it dealing with 'CurrentMember' not packed
in the set.
So I am looking for way to get sutset of [Fund] which has only 'funds' with
exactly the same 'subasset class' as 'CurrentMember'

"Jéjé" wrote:

do you mean that you don't know the "25" value?

"it dependes on CurrentMember property." the currentmember of which
dimension?

do you want something like:
SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = <filtering
dimension>.currentmember.property("SubAsset Class Target"))) ON ROWS
FROM FundCube

and the <filtering dimension> contains the list of possibile values to be
used has the target of the filter.


"martinbx" <martinbx (AT) discussions (DOT) microsoft.com> wrote in message
news:7C971CFF-99D0-402C-991F-8A052AD99B5B (AT) microsoft (DOT) com...
Thank you Milind, but my problem is that I do not know value of :SubAsset
Class" in advance, it dependes on CurrentMember property.

"Milind" wrote:

Try this

SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,
AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = "25")) ON ROWS
FROM FundCube

You can define this in a calculated member if you want

Hope this help

Milind





Reply With Quote
  #8  
Old   
martinbx
 
Posts: n/a

Default Re: MDX: How to filter dimension by member attribute - 08-19-2005 , 04:40 PM



Thank you very much, it helped.

"Brian Altmann" wrote:

Quote:
If your dimension name is [Portfolio Hierarchies] then you should replace it
by the Leaf level name as shown here:

'Count
(
Generate(
{[Portfolio Hierarchies].CurrentMember} as CurrMember,
Filter(
*** Portfolio Hierarchies Leaf Level Name***.Members,
[Portfolio Hierarchies].CurrentMember.Properties("Portfolio Id")=
CurrMember.Current.Properties("Portfolio Id")
)
)
)'

A member property is only valid for the level at which it is defined, so you
have use [Dimension Level].members. If you [Dimension].members you get the
error you have reported.
HTH,
--
Brian Altmann
BI Specialist
Huddle Group S.A (www.huddle.com.ar)
www.geocities.com/brianaltmann/olap.html


"martinbx" wrote:

Thanks for advice Brian. Unfortunatly somebody rase "foodmart2000" database
from our server, so I have to try on our code. So I wrote:

'Count
(
Generate(
{[Portfolio Hierarchies].CurrentMember} as CurrMember,
Filter(
[Portfolio Hierarchies].Members,
[Portfolio Hierarchies].CurrentMember.Properties("Portfolio Id")=
CurrMember.Current.Properties("Portfolio Id")
)
)
)'

I got back an error: "Formula error - property name is not valid: "Portfolio
Id" - an error occuerred during attempt to get a cell value", but if I try
directly to output
[Portfolio Hierarchies].CurrentMember.Properties("Portfolio Id") , I get
back valid answer.
I would appreciate any suggestion on what is going on and how to
fix it.

"Brian Altmann" wrote:

Using the Foodmart dimension Store instead of Funds, and the property "Store
Manager" instead of "SubAsset Class"), is this what you mean? (see Johnson in
query results):

with
member measures.Manager as '[store].currentmember.properties("Store Manager")'
member measures.TotalManager as 'sum( generate ( {[store].currentmember}
as curstor , filter( [store name].members ,
curstor.current.properties("Store Manager") =
[Store].currentmember.properties("Store Manager"))) ,[unit sales] )'
select
{Manager, [unit sales] ,[TotalManager] } on columns,
[Store Name].members on rows
from sales

HTH,
--
Brian Altmann
BI Specialist
Huddle Group S.A (www.huddle.com.ar)
www.geocities.com/brianaltmann/olap.html


"martinbx" wrote:

Hi,
I am trying to do something like this

set [CurrentFund] as
'{[Fund].currentMember}'

member [Measures].[CurrentFund ID] as
' CLng([CurrentFund].Item(0).Item(0).Properties("SubAsset Class"))'

member [Measures].[FundSiblings]
' CStr
(
Filter
(
Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER),
CLng([Fund].CurrentMember.Properties("SubAsset Class")=
[Measures].[CurrentFund ID]
).Count
)

but I made an error somewhere, sinceMDX can not find properties in my set,
but does not have any problem when it dealing with 'CurrentMember' not packed
in the set.
So I am looking for way to get sutset of [Fund] which has only 'funds' with
exactly the same 'subasset class' as 'CurrentMember'

"Jéjé" wrote:

do you mean that you don't know the "25" value?

"it dependes on CurrentMember property." the currentmember of which
dimension?

do you want something like:
SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = <filtering
dimension>.currentmember.property("SubAsset Class Target"))) ON ROWS
FROM FundCube

and the <filtering dimension> contains the list of possibile values to be
used has the target of the filter.


"martinbx" <martinbx (AT) discussions (DOT) microsoft.com> wrote in message
news:7C971CFF-99D0-402C-991F-8A052AD99B5B (AT) microsoft (DOT) com...
Thank you Milind, but my problem is that I do not know value of :SubAsset
Class" in advance, it dependes on CurrentMember property.

"Milind" wrote:

Try this

SELECT {Some Measure} ON COLUMNS,
Filter({ Descendants ([Fund].[All Fund], [Fund].[All Fund].Level,
AFTER)},
([Fund].CurrentMember.Properties("SubAsset Class") = "25")) ON ROWS
FROM FundCube

You can define this in a calculated member if you want

Hope this help

Milind





Reply With Quote
  #9  
Old   
newbie
 
Posts: n/a

Default Re: MDX: How to filter dimension by member attribute - 09-01-2005 , 09:46 AM




How would you do this with a calculated member?

I have the same scenario where I need all the descendants of the
ancestor of the current member that have the same member propery value
as that of the current member.

But I need to make it a calculated member so it shows in the cube.

Thanks...



*** Sent via Developersdex http://www.developersdex.com ***

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.