dbTalk Databases Forums  

"Simple" calculation

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


Discuss "Simple" calculation in the microsoft.public.sqlserver.olap forum.



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

Default "Simple" calculation - 11-22-2004 , 05:35 AM






I have problems with calculations of this kind: sale=price*quantity. If I use
calculated members it will calculate right if you are on leaf level in all
dimensions. But when you go to for example total product it will aggregate
prices and quantity and then multiply the sum of prices with the sum of
quantities. That is very - of cause - very wrong.

The easy way to solve this problem is to use calculated cells. When doing
that you can tell it only to calculate on lowest level in all dimensions and
then the result will be right everywhere (it will then aggregate "sale" in
stead of price an quantity). BUT then performance becomes very bad, even with
smal cubes ...
I have looked at solve order and pass order, but can't figure out if that is
the right way to go.

Thank you in advance for any help!

Regards,
--
Kai Ettrup
BI PARTNER A/S

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

Default RE: "Simple" calculation - 11-22-2004 , 04:21 PM






I have had a similar issue which I solved by creating the calculated field
'sale' as a field in the fact table (or more properly a view based on the
fact table).

Interested in other solutions though...

DG

"Kai Ettrup" wrote:

Quote:
I have problems with calculations of this kind: sale=price*quantity. If I use
calculated members it will calculate right if you are on leaf level in all
dimensions. But when you go to for example total product it will aggregate
prices and quantity and then multiply the sum of prices with the sum of
quantities. That is very - of cause - very wrong.

The easy way to solve this problem is to use calculated cells. When doing
that you can tell it only to calculate on lowest level in all dimensions and
then the result will be right everywhere (it will then aggregate "sale" in
stead of price an quantity). BUT then performance becomes very bad, even with
smal cubes ...
I have looked at solve order and pass order, but can't figure out if that is
the right way to go.

Thank you in advance for any help!

Regards,
--
Kai Ettrup
BI PARTNER A/S

Reply With Quote
  #3  
Old   
Deepak Puri
 
Posts: n/a

Default RE: "Simple" calculation - 11-22-2004 , 11:50 PM



Defining a SQL view with a calculated column like "sale" should work -
this column would drive a cube "sum" measure.

A similar result can be achieved, without a new view, by entering a SQL
formula, like "price * quantity", in the "Source Column" property of the
cube measure. This is discussed as a "derived measure" in the article
below:

http://www.databasejournal.com/featu...10894_3394681_
2
Quote:
...
Unlike calculated members (including, of course, calculated measures),
whose values are created at runtime, based upon the MDX expression(s)
they contain, a derived measure, just as any other cube measure, is
calculated during the cube processing cycle, and is stored within
Analysis Services. In the case of the calculated member, only its
definition is stored, and the values it renders are calculated in memory
when specified in a query. Because only the definition is stored, cube
processing time ("build time") is not materially increased, and, indeed,
depending upon the environment, this might be an appropriate tradeoff.
In our present scenario, however, query processing is the more important
concern, so we lose the primary benefit behind the choice of a
calculated measure to provide the needed values.

Derived measures differ from "ordinary" measures because they take
advantage of the flexibility that Analysis Services offers us in
modifying the source column property for a given measure. Because they
are stored in the cube file, as we have mentioned, they typically mean
more efficient query processing. Derived measures, by their nature, are
calculated prior to the creation of aggregations. (In contrast,
calculated measures are calculated after aggregations are created.) In
general, derived measures make sense if they will be called upon
frequently, as in reporting scenarios such as that of our hypothetical
information consumers. Calculated measures might be a better choice for
values that we expect to be used infrequently, again because the
tradeoff is tipped more in favor of a lower overhead on the cube
processing side, where query response time might not be as high a
priority.

We are limited to creating derived measures from the columns of the fact
table, since MSAS essentially only offers these columns as options in
the measure creation process. However, as many of us have found, a view
can be created to contain columns that lie outside the physical fact
table, making this limitation a bit less restrictive than it might
appear at first blush. Derived measures can extend well beyond simple
math, as we shall see in our example, and can apply conditional logic
and other nuances in derivation of the measure. The syntax obviously has
to fit the database
...
Quote:

- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
  #4  
Old   
Kai Ettrup
 
Posts: n/a

Default RE: "Simple" calculation - 11-23-2004 , 03:01 AM



Thank you for the suggestions. I do it the same way myself with data from a
fact-table, but I forgot to say that this is on write-back data. I am keying
in price and quantity and want the cube to calculate sale. Or it could be
salary and increase-percentage. I think that the performance problems is
caused by the fact that the cube needs to check every cell to see if there is
a number as a result of the cell calculation and that is a lot slower than if
it should only look through cells containing data. Other OLAP products have
ways to overcome this problem (for example "feeders" or "dependencies"). I am
sure there must be a way in MS OLAP as well?

Regards
Kai

"Deepak Puri" wrote:

Quote:
Defining a SQL view with a calculated column like "sale" should work -
this column would drive a cube "sum" measure.

A similar result can be achieved, without a new view, by entering a SQL
formula, like "price * quantity", in the "Source Column" property of the
cube measure. This is discussed as a "derived measure" in the article
below:

http://www.databasejournal.com/featu...10894_3394681_
2

...
Unlike calculated members (including, of course, calculated measures),
whose values are created at runtime, based upon the MDX expression(s)
they contain, a derived measure, just as any other cube measure, is
calculated during the cube processing cycle, and is stored within
Analysis Services. In the case of the calculated member, only its
definition is stored, and the values it renders are calculated in memory
when specified in a query. Because only the definition is stored, cube
processing time ("build time") is not materially increased, and, indeed,
depending upon the environment, this might be an appropriate tradeoff.
In our present scenario, however, query processing is the more important
concern, so we lose the primary benefit behind the choice of a
calculated measure to provide the needed values.

Derived measures differ from "ordinary" measures because they take
advantage of the flexibility that Analysis Services offers us in
modifying the source column property for a given measure. Because they
are stored in the cube file, as we have mentioned, they typically mean
more efficient query processing. Derived measures, by their nature, are
calculated prior to the creation of aggregations. (In contrast,
calculated measures are calculated after aggregations are created.) In
general, derived measures make sense if they will be called upon
frequently, as in reporting scenarios such as that of our hypothetical
information consumers. Calculated measures might be a better choice for
values that we expect to be used infrequently, again because the
tradeoff is tipped more in favor of a lower overhead on the cube
processing side, where query response time might not be as high a
priority.

We are limited to creating derived measures from the columns of the fact
table, since MSAS essentially only offers these columns as options in
the measure creation process. However, as many of us have found, a view
can be created to contain columns that lie outside the physical fact
table, making this limitation a bit less restrictive than it might
appear at first blush. Derived measures can extend well beyond simple
math, as we shall see in our example, and can apply conditional logic
and other nuances in derivation of the measure. The syntax obviously has
to fit the database
...



- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
  #5  
Old   
Kai Ettrup
 
Posts: n/a

Default RE: "Simple" calculation - 11-23-2004 , 03:07 AM



Thank you both for you suggestions, but I forgot to say that I am working on
Write-back data so I can't use a view. From fact table I always calculate
sale before transfering to the cube.

Regards,
Kai

"Deepak Puri" wrote:

Quote:
Defining a SQL view with a calculated column like "sale" should work -
this column would drive a cube "sum" measure.

A similar result can be achieved, without a new view, by entering a SQL
formula, like "price * quantity", in the "Source Column" property of the
cube measure. This is discussed as a "derived measure" in the article
below:

http://www.databasejournal.com/featu...10894_3394681_
2

...
Unlike calculated members (including, of course, calculated measures),
whose values are created at runtime, based upon the MDX expression(s)
they contain, a derived measure, just as any other cube measure, is
calculated during the cube processing cycle, and is stored within
Analysis Services. In the case of the calculated member, only its
definition is stored, and the values it renders are calculated in memory
when specified in a query. Because only the definition is stored, cube
processing time ("build time") is not materially increased, and, indeed,
depending upon the environment, this might be an appropriate tradeoff.
In our present scenario, however, query processing is the more important
concern, so we lose the primary benefit behind the choice of a
calculated measure to provide the needed values.

Derived measures differ from "ordinary" measures because they take
advantage of the flexibility that Analysis Services offers us in
modifying the source column property for a given measure. Because they
are stored in the cube file, as we have mentioned, they typically mean
more efficient query processing. Derived measures, by their nature, are
calculated prior to the creation of aggregations. (In contrast,
calculated measures are calculated after aggregations are created.) In
general, derived measures make sense if they will be called upon
frequently, as in reporting scenarios such as that of our hypothetical
information consumers. Calculated measures might be a better choice for
values that we expect to be used infrequently, again because the
tradeoff is tipped more in favor of a lower overhead on the cube
processing side, where query response time might not be as high a
priority.

We are limited to creating derived measures from the columns of the fact
table, since MSAS essentially only offers these columns as options in
the measure creation process. However, as many of us have found, a view
can be created to contain columns that lie outside the physical fact
table, making this limitation a bit less restrictive than it might
appear at first blush. Derived measures can extend well beyond simple
math, as we shall see in our example, and can apply conditional logic
and other nuances in derivation of the measure. The syntax obviously has
to fit the database
...



- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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.