Showing posts with label scoped. Show all posts
Showing posts with label scoped. Show all posts

Saturday, February 25, 2012

Scoped calulated measures for unrelated dimensions

Hi,

I am not sure if this is a correct way to design this,

Here is my scenario:

We are migrating an existing databwarehouse application from vb, which used to pull out records using the criteria provided in the input screen. The input conditions are many and multiple selections and combinations constitute the final data that is returned in excel format.

Most of the input conditions specified are filters or slicing of data, which we have modelled as dimensions, and they were existing tables in the database. other filters for dicing the measures which is modelled as the fact were also existing tables.

There are some input conditions that are not dimensions at all, meaning there are no tables which exists for them.

One for example, a collection of 4 values (A,B,C,D) , when A is selected the output excel comes in a paticular format, with calculations specific to a paticular region. and so on for B,C,D.etc

1. Now if I model this as a dimension in ssas 2005, I dont have related fact data for this. what should I do?

2. Anyway , I have created a dimension in ssas 2005 that contains this data. I now want to create calculations (either named or calc measures) that dynamically have formula x+y if the browsed value/queried value of the unrelated dimension is A and a different formula if the viewed dimensiion value is B,etc

meaning I want to have a dynamic calculated measure that changes its formula based on the unrelated dimension that is used in the query's row or column

Is this possible? is this the correct way to model this problem?

Regards

Yes, it is possible. The very related example how to do it - is the Time Intelligence Wizard. When you run it, it modifies DSV (you don't even need to create artificial table for A,B,C and D !) to add such factless attribute members, and then in MDX Script it assigns to them formulas. I.e., you MDX Script would look something like

ArtificialAttribute.A = formulaforA;

ArtificialAttribute.B = formulaforY;

...

etc.

|||

On this note, can I ask you a question.
Isn't using time intelligence an expensive operation during querying?

Rgds

Hari

|||

Sorry, but this question isn't posed in a way that it is possible to answer. It's like asking "Isn't running SQL queries expensive ?". And the answer to this question is also unrelated to the original problem.

Tuesday, February 21, 2012

Scoped Calculations and Aggregate

I have a measure which is defined as 0 and then Scope'd for certain dimensions to be a percent of the total as below:

CREATE MEMBER [Measures].[Revenue Percent] AS 0;

SCOPE ([Measures].[Revenue Percent]);

THIS = ([Measures].[Gross Revenue]) / ([Measures].[Gross Revenue], [Area].[Sales Area].[All], [Direct Response].[DRS].[All])

SCOPE (Descendants([Area].[Sales Area].&[2], 1, SELF_AND_AFTER));

THIS = ([Measures].[Gross Revenue])

/ ([Measures].[Gross Revenue], [Area].[Sales Area].&[2], [Direct Response].[DRS].[All]);

END SCOPE;

END SCOPE;

This calculation works fine when I am browsing the cube as I would expect. I can create calculated members on my date dimension and the measure is calculated correctly using Aggregate({date1, date2, date3, etc}) function. However as soon as I change this calculation to use "relative" sets of members it simply returns 0.

So if I have the calcuation,

MEMEBER [Measures].[YTD Revenue Percent] AS AGGREGATE(YTD(date4), [Measures].[Revenue Percent])

it will always return 0. Even if I create the YTD portion as a set first and then aggregate that it still returns 0. However change the ytd(Date4) to something like {date1Big Smileate4} and the calculation will work.

Has anyone else seen this sort of behaviour, or can point me in the direction of information as to why it doesn't work?

Thanks in advance

Mike

PS: The date dimension is correctly figured and the member names date1 etc are just syntax for shortening the full date in the post.

{date1ate4} Should read {date1 : date4} - Sorry just seen that once it is posted.