Showing posts with label dimension. Show all posts
Showing posts with label dimension. Show all posts

Monday, March 26, 2012

How to apply an MDX filter that doesn't affect roll-up?

Take the Employee dimension of Adventure Works Cube. I want to see a list of all Male Employees and the total Reseller-Sales they supervise. My MDX query looks like this

Select [Measures].[Reseller Sales-Sales Amount] on Columns,
non empty [Employee].[Employees].AllMembers on Rows
from [Analysis Services Tutorial]
where [Employee].[Gender].&[M]

and I get a result of

Reseller Sales-Sales Amount
All Employees $44,244,815.17
Ken J. Sánchez $44,244,815.17
Brian S. Welcker $44,244,815.17
Ranjit R. Varkey Chudukatil $4,509,888.93
Stephen Y. Jiang $39,562,401.78
David R. Campbell $3,729,945.35
Garrett R. Vargas $3,609,447.22
Jos Edvaldo. Saraiva $5,926,418.36
Michael G. Blythe $9,293,903.01
Shu K. Ito $6,427,005.56
Stephen Y. Jiang $1,092,123.86
Tete A. Mensa-Annan $2,312,545.69
Tsvi Michael. Reiter $7,171,012.75
Syed E. Abbas $172,524.45

ok so it gave me all the male employees, which is good, but the sales amounts are incorrect, it is only summing

the sales of the male underlings. Ken J. Sánchez actually has 80 million in sales under him, Stephen Y. Jiang has 63 million, etc... The Cube is not counting the female underlings sales. How do I include everything in the roll-ups, but only return the male supervisors?

Thanks

Todd Wilder

Select [Measures].[Reseller Sales-Sales Amount] on Columns,
non empty

Exists(

[Employee].[Employees].AllMembers

,[Employee].[Gender].&[M]

) on Rows
from [Analysis Services Tutorial]

That should only show male employees on rows, but the totals should reflect all employees under them.|||

There seems to be a slight twist to this, since Employee is a parent-child dimension. Apparently, using the parent-child hierarchy, a member can "exist" with an attribute like [Employee].[Gender].&[M] if any of its descendants are male. But a member of the key attribute hierarchy works as with regular dimensions. So LinkMember() can be used to map key attribute members to the corresponding parent-child members, like:

Select [Measures].[Reseller Sales Amount] on Columns,
non empty Generate(exists([Employee].[Employee].[Employee],
[Employee].[Gender].&[M]),
{LinkMember([Employee].[Employee].CurrentMember,
[Employee].[Employees])}) on Rows
from [Adventure Works]

In this case, there is a discrepancy between the 2 queries of a single (non empty) member - Amy E. Alberts (female):

Select [Measures].[Reseller Sales Amount] on Columns,
non empty exists([Employee].[Employees].Members,
[Employee].[Gender].&[M]) -
Generate(exists([Employee].[Employee].[Employee],
[Employee].[Gender].&[M]),
{LinkMember([Employee].[Employee].CurrentMember,
[Employee].[Employees])})on Rows
from [Adventure Works]
--
Reseller Sales Amount
All Employees $80,450,596.98
Amy E. Alberts $15,535,946.26

how to alternate the colours on a column with parent-child dimension

Hi

I have a matrix and one of the column has a parent-child dimension, how can I code to have alternate colours for the column?

Thanks a lot for your help

G

Since this is a matrix, you would need to follow an approach similar to http://blogs.msdn.com/chrishays/archive/2004/08/30/GreenBarMatrix.aspx

-- Robert

|||thanks a lot for your answer!sql

Wednesday, March 21, 2012

How to add YTD (Calculation) to Time Dimension?

Is there any you can add YTD to Time Dimension as attribute? Or it has to be Calculation? Then how do we do this? Is this need to base on Dimension or Measure? I would prefer this to be base on dimension and show in Time dimension hierarchy.

Any inputs on this are highly appreciated.

If you are using Analysis Services 2005 you can open the cube editor and then click on the "Add Business Intelligence" button you will get a wizard that will guide you through the process of adding a "Period Calculations" attribute hierarchy to your time dimension which can be used to support YTD, QTD, MTD and other period calculations.

The following is a link to an excellent article on the "Time Intelligence" wizard that was published in SQLServer magazine:

http://www.windowsitpro.com/Article/ArticleID/46157/46157.html

|||

Although you need to be aware that some of the calculations produced by the Time Intelligence Wizard, including the YTD calculation, don't actually work. See:

http://spaces.msn.com/members/cwebbbi/Blog/cns!1pi7ETChsJ1un_2s41jm9Iyg!379.entry

|||

There are several ways to accomplish this. If your users want a way to select Monthly values vs, QTD, YTD from a selector/slicer you will need to create a Time Utility Dim or a Time Ref Dim.

This Dim will only contain one member for the lowest level of detail. ie. Month or Daily. You would then create calculated members to compute YTD and anyother values that are based on what the user has selected in the Time Dim.

|||Can this be done in AS 2005?

How to add YTD (Calculation) to Time Dimension?

Is there any you can add YTD to Time Dimension as attribute? Or it has to be Calculation? Then how do we do this? Is this need to base on Dimension or Measure? I would prefer this to be base on dimension and show in Time dimension hierarchy.

Any inputs on this are highly appreciated.

If you are using Analysis Services 2005 you can open the cube editor and then click on the "Add Business Intelligence" button you will get a wizard that will guide you through the process of adding a "Period Calculations" attribute hierarchy to your time dimension which can be used to support YTD, QTD, MTD and other period calculations.

The following is a link to an excellent article on the "Time Intelligence" wizard that was published in SQLServer magazine:

http://www.windowsitpro.com/Article/ArticleID/46157/46157.html

|||

Although you need to be aware that some of the calculations produced by the Time Intelligence Wizard, including the YTD calculation, don't actually work. See:

http://spaces.msn.com/members/cwebbbi/Blog/cns!1pi7ETChsJ1un_2s41jm9Iyg!379.entry

|||

There are several ways to accomplish this. If your users want a way to select Monthly values vs, QTD, YTD from a selector/slicer you will need to create a Time Utility Dim or a Time Ref Dim.

This Dim will only contain one member for the lowest level of detail. ie. Month or Daily. You would then create calculated members to compute YTD and anyother values that are based on what the user has selected in the Time Dim.

|||Can this be done in AS 2005?

How to add time dependent calculed mesure

Is there a way to add time dependent calculed mesure for ex (Delta% of a standard mesure which represent its evolution within the time dimension)

Regards

I guess you're looking for something like this (from Foodmart 2000):

with member [Measures].[Delta] as '[Measures].[Unit Sales]-([Measures].[Unit Sales],[Time].currentmember.lag(1))'

select {[Measures].[Unit Sales],[Measures].[Delta]} on 0,
{[Time].members} on 1
from sales