Showing posts with label dimensions. Show all posts
Showing posts with label dimensions. Show all posts

Friday, March 23, 2012

How to create Calculations that do not change when dimensions are added.

I would like to calculate the total business done for a week irrespective of the dimension used and I have created a member ([Measures].ForAWeekOfYear) for the same. The Percent1 member calculates the percentage of business done by a company.

with member [Measures].ForAWeekOfYear as
sum( [Dimdate].[Week Of Year] , [Measures].[TotalBusiness] )
member Measures.Percent1 as [Measures].[TotalBusiness]/[Measures].ForAWeekOfYear
select { [Measures].ForAWeekOfYear , ( Measures.Percent1 ) } on 0,
{ [Dim Customer].[Company].members * [Dimdate].[Week Of Year].Members} on 1
from [Account]

The problem I have if I use the above MDX expression is that the calculation gets split based on the Customer dimension and I assume that this is how the query should work. I assume I have to use the SCOPE statement, but not sure how to use it.

Please note that I am trying to execute this in Management console and not within a cube.

If you don't want your calculation to depend on Customer dimension, you should include Root(Customer). If you want to abstract from all of the dimensions in the cube - use Root().

HTH,

Mosha (http://www.mosha.com/msolap)

Wednesday, March 7, 2012

How to count distinct members and keep good performance

Hi all,

I have a simple cube with only one measure : "Amount", I have three dimensions Supplier, Category and Company.

I would like to display a matrix with Categories as rows, company as columns, the amount and the number of distinct suppliers who appaers for each category/company.

I tried to create a calculated measure like this:

Count(Crossjoin({[D Supplier].[Supplier Code].members}, {[Measures].[Amount]}), EXCLUDEEMPTY)

The result is OK, but when I add this calculated Measure to my query the execution time jumps from a few seconds (<10) to a few minutes. Am I missing something ?

Anyone have an idea to do this in a better way ?

On-the-fly distinct counting will be always slow. Any reason not to implement a distinct count on a separate measure group?|||

Indeed adding a separate measure group did the trick.

Thanks.

|||

Now I have another problem, for aggregating the Distinct Count, in the Cube browser it works properly, but in SSRS in a matrix it doesn't. As the query returns flat result, if I Sum the distinct count measure I have more suppliers than I should in the totals, the matrix just sum the values from the query.

How can I keep my Distinct Count working in a matrix ?

Is there any way to create the same measure but without the link to a particular dimension. What I have in mind is returning two columns for my distinctcount, one with the detailed count, one for the aggregated total by category. But I don't see how I can achieve this. Any idea ?

|||Create a calculated measure that includes the distinct count measure and the ALL member of all dimensions included in the query.|||Try using the Aggregate() function in the matrix instead of Sum() as exlained in more details here.|||Thanks a lot that solved my problem.

How to count distinct members and keep good performance

Hi all,

I have a simple cube with only one measure : "Amount", I have three dimensions Supplier, Category and Company.

I would like to display a matrix with Categories as rows, company as columns, the amount and the number of distinct suppliers who appaers for each category/company.

I tried to create a calculated measure like this:

Count(Crossjoin({[D Supplier].[Supplier Code].members}, {[Measures].[Amount]}), EXCLUDEEMPTY)

The result is OK, but when I add this calculated Measure to my query the execution time jumps from a few seconds (<10) to a few minutes. Am I missing something ?

Anyone have an idea to do this in a better way ?

On-the-fly distinct counting will be always slow. Any reason not to implement a distinct count on a separate measure group?|||

Indeed adding a separate measure group did the trick.

Thanks.

|||

Now I have another problem, for aggregating the Distinct Count, in the Cube browser it works properly, but in SSRS in a matrix it doesn't. As the query returns flat result, if I Sum the distinct count measure I have more suppliers than I should in the totals, the matrix just sum the values from the query.

How can I keep my Distinct Count working in a matrix ?

Is there any way to create the same measure but without the link to a particular dimension. What I have in mind is returning two columns for my distinctcount, one with the detailed count, one for the aggregated total by category. But I don't see how I can achieve this. Any idea ?

|||Create a calculated measure that includes the distinct count measure and the ALL member of all dimensions included in the query.|||Try using the Aggregate() function in the matrix instead of Sum() as exlained in more details here.|||Thanks a lot that solved my problem.

Friday, February 24, 2012

How to count distinct members and keep good performance

Hi all,

I have a simple cube with only one measure : "Amount", I have three dimensions Supplier, Category and Company.

I would like to display a matrix with Categories as rows, company as columns, the amount and the number of distinct suppliers who appaers for each category/company.

I tried to create a calculated measure like this:

Count(Crossjoin({[D Supplier].[Supplier Code].members}, {[Measures].[Amount]}), EXCLUDEEMPTY)

The result is OK, but when I add this calculated Measure to my query the execution time jumps from a few seconds (<10) to a few minutes. Am I missing something ?

Anyone have an idea to do this in a better way ?

Try

Count(NonEmptyCrossjoin({[D Supplier].[Supplier Code].members}, {[Measures].[Amount]})

|||Thanks for the answer, but I still have very long execution time when using this expression.|||How many cells are there in the query? If there are many cells, then the poor performance is likely due to the AS server using a slow cell-by-cell query execution plan. If you see a single CPU pegged during query execution on the AS server then it is an indication of running such a slow query plan. Improving performance for this kind of queries is one of the proposed work items for the next major release of the product.