Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDX-Percent of parent

Status
Not open for further replies.

jiuba

Programmer
Jun 21, 2003
3
ES
Hello. I have a problem with the calculated members.
When I have to calculate the total percent for two or more dimension I put this code

([Measures].[Part]/([Measures].[Part ],[Country].[All Country],[Product].[All Product]))

and its ok but the problem if a have to calculate the percent of a ancestor or a parent. If I put this code

([Measures].[Part]/([Measures].[Part],[Country].parent),[Product].Parent)

the result is always bad but if I put this code(the same but only for one dimension)

([Measures].[Part]/([Measures].[Part],[Country].parent))

its ok.

Can you help me please. Thanks.
 
From :

In constructing MDX statements, it is often necessary to relate a current member value to others in the cube hierarchy. MDX has many methods that can be applied to a member to traverse this hierarchy. The most commonly used ones are PREVMEMBER, CURRENTMEMBER, and PARENT.
Using these methods, it is easy to derive an MDX statement that calculates the percentage of sales within a city as a percentage of the state's sales:

WITH MEMBER MEASURES.PercentageSales
AS '([Store].CURRENTMEMBER,
MEASURES.[Unit Sales]) / ([Store].CURRENTMEMBER.PARENT,
MEASURES.[Unit Sales])',
FORMAT_STRING = '#.00%'
SELECT {MEASURES.[Unit Sales],
MEASURES.PercentageSales} ON COLUMNS,
NON EMPTY {[Store].[Store City].MEMBERS} ON ROWS
FROM [Sales]


In this example, all empty rows have been eliminated using the NON EMPTY statement. This statement is a form of filtering, which will be discussed later. In addition, if you wanted to display sales profit and the incremental change to the previous time dimension, the MDX statement would read:

WITH MEMBER MEASURES.ProfitGrowth AS
'(MEASURES.[Profit]) - (MEASURES.[Profit], Time.PrevMember)',
FORMAT_STRING = '###,###.00'
SELECT {MEASURES.[Profit],
MEASURES.ProfitGrowth} ON COLUMNS,
{GENERATE([Time].[1997].CHILDREN,
{[Time].CURRENTMEMBER,
[Time].CURRENTMEMBER.CHILDREN})} ON ROWS
FROM [Sales]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top