dbTalk Databases Forums  

String Calculated Measures

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


Discuss String Calculated Measures in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andrew Wilkie
 
Posts: n/a

Default String Calculated Measures - 06-23-2006 , 03:09 AM






I am using analysis services 2000. I have a measure which returns the
member property of a dimension. What I want to do is only return this
property if another measure is <> 0. This I can do by using the IIF
funtion. My only problem is that when the IIF statement is false, I can
only get it to return a blank string, not a null value. Therefore when
I output the results using proclarity it doesn't remove the blank rows
because they are not null.

Is there a way around this?

Any help appreciated



*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: String Calculated Measures - 06-23-2006 , 05:42 AM






Apart from upgrading to AS2005 I don't think there is anyway around
this.

If you were hand writing your MDX you could use the Filter() function to
get rid of the empty strings. But the IIF() function in AS2k is limited
to returning the same data type for both the true and false arguments.
It can either return one of two strings, or one of two numeric
expressions and only the numeric expressions can return null.

--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <ux3FNxplGHA.3740 (AT) TK2MSFTNGP02 (DOT) phx.gbl>, trekkie95
@hotmail.com says...
Quote:
I am using analysis services 2000. I have a measure which returns the
member property of a dimension. What I want to do is only return this
property if another measure is <> 0. This I can do by using the IIF
funtion. My only problem is that when the IIF statement is false, I can
only get it to return a blank string, not a null value. Therefore when
I output the results using proclarity it doesn't remove the blank rows
because they are not null.

Is there a way around this?

Any help appreciated



*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #3  
Old   
Andrew Wilkie
 
Posts: n/a

Default Re: String Calculated Measures - 06-23-2006 , 07:51 AM





thanks for the help

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #4  
Old   
michael v
 
Posts: n/a

Default Re: String Calculated Measures - 06-23-2006 , 03:16 PM



but i saw a solutin once - think it was deepac

where u make another calc measure and use isempty and then set it to
null.....

cannot remember the syntax - hope it makes sence


"Darren Gosbell" <jam (AT) newsgroups (DOT) nospam> wrote

Quote:
Apart from upgrading to AS2005 I don't think there is anyway around
this.

If you were hand writing your MDX you could use the Filter() function to
get rid of the empty strings. But the IIF() function in AS2k is limited
to returning the same data type for both the true and false arguments.
It can either return one of two strings, or one of two numeric
expressions and only the numeric expressions can return null.

--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <ux3FNxplGHA.3740 (AT) TK2MSFTNGP02 (DOT) phx.gbl>, trekkie95
@hotmail.com says...
I am using analysis services 2000. I have a measure which returns the
member property of a dimension. What I want to do is only return this
property if another measure is <> 0. This I can do by using the IIF
funtion. My only problem is that when the IIF statement is false, I can
only get it to return a blank string, not a null value. Therefore when
I output the results using proclarity it doesn't remove the blank rows
because they are not null.

Is there a way around this?

Any help appreciated



*** Sent via Developersdex http://www.developersdex.com ***




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

Default Re: String Calculated Measures - 06-23-2006 , 04:48 PM



Michael, you're right in your recollection - though the original
solution was posted perhaps by George Spofford:

http://groups.google.com/group/micro...olap/msg/cec78
b442eb1c21e
Quote:
iif() problem

From: Deepak Puri
Date: Wed, Apr 20 2005 5:42 pm
Groups: microsoft.public.sqlserver.olap

There is a well-known issue when combining a string with NULL in iif(),
which you may be encountering. Using a second measure to "hide" the text
may work, like:

[Measures].[Text1] :

Right([Measures].[Codigo Data Venc Titulo],2) + "/" +
Mid([Measures].[Codigo Data Venc Titulo], 5, 2) + "/" +
Left([Measures].[Codigo Data Venc Titulo],4)


[Measures].[Text2] :

iif(IsEmpty([Measures].[Codigo Data Venc Titulo]),
NULL, [Measures].[Text1])
...
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #6  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: String Calculated Measures - 06-23-2006 , 07:21 PM



Cool, I had not seen that one - sorry about that Andrew.

It looks like it "tricks" AS2k by passing it a null and an expression
rather than a null and a string.

For those of us lucky enough to have upgraded to AS2k5 this is no longer
an issue as the iif() function has been enhanced to not require that the
two return arguements be of the same type.

--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <uTg256wlGHA.4268 (AT) TK2MSFTNGP05 (DOT) phx.gbl>,
deepak_puri (AT) progressive (DOT) com says...
Quote:
Michael, you're right in your recollection - though the original
solution was posted perhaps by George Spofford:

http://groups.google.com/group/micro...olap/msg/cec78
b442eb1c21e

iif() problem

From: Deepak Puri
Date: Wed, Apr 20 2005 5:42 pm
Groups: microsoft.public.sqlserver.olap

There is a well-known issue when combining a string with NULL in iif(),
which you may be encountering. Using a second measure to "hide" the text
may work, like:

[Measures].[Text1] :

Right([Measures].[Codigo Data Venc Titulo],2) + "/" +
Mid([Measures].[Codigo Data Venc Titulo], 5, 2) + "/" +
Left([Measures].[Codigo Data Venc Titulo],4)


[Measures].[Text2] :

iif(IsEmpty([Measures].[Codigo Data Venc Titulo]),
NULL, [Measures].[Text1])
..



- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


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.