dbTalk Databases Forums  

Divide by Zero - using a "variable" to save a value

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


Discuss Divide by Zero - using a "variable" to save a value in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Vinicius Bellino
 
Posts: n/a

Default Divide by Zero - using a "variable" to save a value - 10-11-2004 , 02:48 PM






Hi,

Does anybody know if there's a way to save a value in something like a
variable inside a mdx formula?

For example, suppose that I have to do a divide by zero test, using an
iif in the denominator, but this demoninator is calculated by a hard
formula, so if I calculate it just for test if it's zero and then
calculate it again in the denominator, if it's not zero, I spend
double time (disconsidering the cache effect). A way I know but I
don't know if it's the best option is to use a sum with a named set
like:

Sum({HARD_FORMULA} as HardFormulaSet,
iif (HardFormulaSet.Item(0).Item(0) = 0,
NULL,
a / HardFormulaSet.Item(0).Item(0)))

Thanks in advance,

Vinicius Bellino

Reply With Quote
  #2  
Old   
Tore Johnsen
 
Posts: n/a

Default Re: Divide by Zero - using a "variable" to save a value - 10-13-2004 , 05:01 AM






To avoid repeating the formula you could keep the formula in an auxiliary
hidden measure and make the test in another visible measure, calling the
first.
"Vinicius Bellino" <vbellino (AT) uol (DOT) com.br> escreveu na mensagem
news:93d12908.0410111148.1ec2f73 (AT) posting (DOT) google.com...
Quote:
Hi,

Does anybody know if there's a way to save a value in something like a
variable inside a mdx formula?

For example, suppose that I have to do a divide by zero test, using an
iif in the denominator, but this demoninator is calculated by a hard
formula, so if I calculate it just for test if it's zero and then
calculate it again in the denominator, if it's not zero, I spend
double time (disconsidering the cache effect). A way I know but I
don't know if it's the best option is to use a sum with a named set
like:

Sum({HARD_FORMULA} as HardFormulaSet,
iif (HardFormulaSet.Item(0).Item(0) = 0,
NULL,
a / HardFormulaSet.Item(0).Item(0)))

Thanks in advance,

Vinicius Bellino



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.