dbTalk Databases Forums  

Converting Data Types in Calculated Members

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


Discuss Converting Data Types in Calculated Members in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Hwang
 
Posts: n/a

Default Converting Data Types in Calculated Members - 06-09-2004 , 05:28 PM






Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David

Reply With Quote
  #2  
Old   
Chris Webb
 
Posts: n/a

Default RE: Converting Data Types in Calculated Members - 06-10-2004 , 03:50 AM






Hi David,

You can use all the standard VBA functions to convert types in calculated members, eg CINT, CSTR etc. As for the IIF statement, strictly speaking it can only return either two strings or two numeric values, but there is a way round this by getting the IIF statement to return the values of two calculated measures. Here's an example that shows everything in action:

WITH
MEMBER MEASURES.TRUERESULT AS '"Is Jones"'
MEMBER MEASURES.FALSERESULT AS '0'
MEMBER MEASURES.COMPARE AS
'IIF(VBA!CSTR(STORE.CURRENTMEMBER.PROPERTIES("Stor e Manager"))="Jones", MEASURES.TRUERESULT, MEASURES.FALSERESULT)'
SELECT {MEASURES.COMPARE} ON 0,
STORE.[STORE NAME].MEMBERS ON 1
FROM SALES

HTH,

Chris

"David Hwang" wrote:

Quote:
Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David


Reply With Quote
  #3  
Old   
David Hwang
 
Posts: n/a

Default Re: Converting Data Types in Calculated Members - 06-10-2004 , 10:18 AM



Thanks a lot, Chris. That was exactly what I needed.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Quote:
Hi David,

You can use all the standard VBA functions to convert types in calculated members, eg CINT, CSTR etc. As for the IIF statement, strictly speaking it can only return either two strings or two numeric values, but there is a way round this by getting the IIF statement to return the values of two calculated measures. Here's an example that shows everything in action:

WITH
MEMBER MEASURES.TRUERESULT AS '"Is Jones"'
MEMBER MEASURES.FALSERESULT AS '0'
MEMBER MEASURES.COMPARE AS
'IIF(VBA!CSTR(STORE.CURRENTMEMBER.PROPERTIES("Stor e Manager"))="Jones", MEASURES.TRUERESULT, MEASURES.FALSERESULT)'
SELECT {MEASURES.COMPARE} ON 0,
STORE.[STORE NAME].MEMBERS ON 1
FROM SALES

HTH,

Chris


"David Hwang" wrote:

Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David


Reply With Quote
  #4  
Old   
David Hwang
 
Posts: n/a

Default Re: Converting Data Types in Calculated Members - 06-10-2004 , 04:16 PM



How do you use the "with..." statement in the Calculated Member
Builder in Analsys Manager? I don't really want to specify any
dimensions in that value expression.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Quote:
Hi David,

You can use all the standard VBA functions to convert types in calculated members, eg CINT, CSTR etc. As for the IIF statement, strictly speaking it can only return either two strings or two numeric values, but there is a way round this by getting the IIF statement to return the values of two calculated measures. Here's an example that shows everything in action:

WITH
MEMBER MEASURES.TRUERESULT AS '"Is Jones"'
MEMBER MEASURES.FALSERESULT AS '0'
MEMBER MEASURES.COMPARE AS
'IIF(VBA!CSTR(STORE.CURRENTMEMBER.PROPERTIES("Stor e Manager"))="Jones", MEASURES.TRUERESULT, MEASURES.FALSERESULT)'
SELECT {MEASURES.COMPARE} ON 0,
STORE.[STORE NAME].MEMBERS ON 1
FROM SALES

HTH,

Chris

"David Hwang" wrote:

Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David


Reply With Quote
  #5  
Old   
David Hwang
 
Posts: n/a

Default Re: Converting Data Types in Calculated Members - 06-11-2004 , 07:50 AM



How do you use the "with..." statement in the Calculated Member
Builder in Analsys Manager? I don't really want to specify any
dimensions in that value expression.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Quote:
Hi David,

You can use all the standard VBA functions to convert types in calculated members, eg CINT, CSTR etc. As for the IIF statement, strictly speaking it can only return either two strings or two numeric values, but there is a way round this by getting the IIF statement to return the values of two calculated measures. Here's an example that shows everything in action:

WITH
MEMBER MEASURES.TRUERESULT AS '"Is Jones"'
MEMBER MEASURES.FALSERESULT AS '0'
MEMBER MEASURES.COMPARE AS
'IIF(VBA!CSTR(STORE.CURRENTMEMBER.PROPERTIES("Stor e Manager"))="Jones", MEASURES.TRUERESULT, MEASURES.FALSERESULT)'
SELECT {MEASURES.COMPARE} ON 0,
STORE.[STORE NAME].MEMBERS ON 1
FROM SALES

HTH,

Chris

"David Hwang" wrote:

Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David


Reply With Quote
  #6  
Old   
Chris Webb
 
Posts: n/a

Default Re: Converting Data Types in Calculated Members - 06-15-2004 , 03:34 AM



Sorry for the late reply... in the calculated member all you need to do is copy and paste the calculated member definition from within the single quotes in the WITH clause, ie
"Is Jones"
and
0
for the two calculated members in the query I gave below.

Chris

"David Hwang" wrote:

Quote:
How do you use the "with..." statement in the Calculated Member
Builder in Analsys Manager? I don't really want to specify any
dimensions in that value expression.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Hi David,

You can use all the standard VBA functions to convert types in calculated members, eg CINT, CSTR etc. As for the IIF statement, strictly speaking it can only return either two strings or two numeric values, but there is a way round this by getting the IIF statement to return the values of two calculated measures. Here's an example that shows everything in action:

WITH
MEMBER MEASURES.TRUERESULT AS '"Is Jones"'
MEMBER MEASURES.FALSERESULT AS '0'
MEMBER MEASURES.COMPARE AS
'IIF(VBA!CSTR(STORE.CURRENTMEMBER.PROPERTIES("Stor e Manager"))="Jones", MEASURES.TRUERESULT, MEASURES.FALSERESULT)'
SELECT {MEASURES.COMPARE} ON 0,
STORE.[STORE NAME].MEMBERS ON 1
FROM SALES

HTH,

Chris

"David Hwang" wrote:

Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David



Reply With Quote
  #7  
Old   
David Hwang
 
Posts: n/a

Default Re: Converting Data Types in Calculated Members - 06-15-2004 , 04:40 PM



Actually, I meant is it still possible to use a WITH clause to
dynamically generate new calculated members while using the Calculated
Member Builder. I don't want to actually save calculated members just
for a string or to use NULL. Basically, I would like to paste that
entire statement below into the Calculated Member Builder and store
that as my new calculated member, but it's giving me an error because
it doesn't seem to like the WITH statement.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Quote:
Sorry for the late reply... in the calculated member all you need to do is copy and paste the calculated member definition from within the single quotes in the WITH clause, ie
"Is Jones"
and
0
for the two calculated members in the query I gave below.

Chris

"David Hwang" wrote:

How do you use the "with..." statement in the Calculated Member
Builder in Analsys Manager? I don't really want to specify any
dimensions in that value expression.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Hi David,

You can use all the standard VBA functions to convert types in calculated members, eg CINT, CSTR etc. As for the IIF statement, strictly speaking it can only return either two strings or two numeric values, but there is a way round this by getting the IIF statement to return the values of two calculated measures. Here's an example that shows everything in action:

WITH
MEMBER MEASURES.TRUERESULT AS '"Is Jones"'
MEMBER MEASURES.FALSERESULT AS '0'
MEMBER MEASURES.COMPARE AS
'IIF(VBA!CSTR(STORE.CURRENTMEMBER.PROPERTIES("Stor e Manager"))="Jones", MEASURES.TRUERESULT, MEASURES.FALSERESULT)'
SELECT {MEASURES.COMPARE} ON 0,
STORE.[STORE NAME].MEMBERS ON 1
FROM SALES

HTH,

Chris

"David Hwang" wrote:

Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David


Reply With Quote
  #8  
Old   
David Hwang
 
Posts: n/a

Default Re: Converting Data Types in Calculated Members - 06-15-2004 , 04:49 PM



Actually, I meant is it still possible to use a WITH clause to
dynamically generate new calculated members while using the Calculated
Member Builder. I don't want to actually save calculated members just
for a string or to use NULL. Basically, I would like to paste that
entire statement below into the Calculated Member Builder and store
that as my new calculated member, but it's giving me an error because
it doesn't seem to like the WITH statement.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Quote:
Sorry for the late reply... in the calculated member all you need to do is copy and paste the calculated member definition from within the single quotes in the WITH clause, ie
"Is Jones"
and
0
for the two calculated members in the query I gave below.

Chris

"David Hwang" wrote:

How do you use the "with..." statement in the Calculated Member
Builder in Analsys Manager? I don't really want to specify any
dimensions in that value expression.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Hi David,

You can use all the standard VBA functions to convert types in calculated members, eg CINT, CSTR etc. As for the IIF statement, strictly speaking it can only return either two strings or two numeric values, but there is a way round this by getting the IIF statement to return the values of two calculated measures. Here's an example that shows everything in action:

WITH
MEMBER MEASURES.TRUERESULT AS '"Is Jones"'
MEMBER MEASURES.FALSERESULT AS '0'
MEMBER MEASURES.COMPARE AS
'IIF(VBA!CSTR(STORE.CURRENTMEMBER.PROPERTIES("Stor e Manager"))="Jones", MEASURES.TRUERESULT, MEASURES.FALSERESULT)'
SELECT {MEASURES.COMPARE} ON 0,
STORE.[STORE NAME].MEMBERS ON 1
FROM SALES

HTH,

Chris

"David Hwang" wrote:

Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David


Reply With Quote
  #9  
Old   
Chris Webb
 
Posts: n/a

Default Re: Converting Data Types in Calculated Members - 06-16-2004 , 03:23 AM



Hi David,

I'm not sure what exactly you want to do, but certainly a WITH clause can only be used with an MDX SELECT statement. The query below would translate to three different calculated members, each created separately, on the server.

Regards,

Chris

"David Hwang" wrote:

Quote:
Actually, I meant is it still possible to use a WITH clause to
dynamically generate new calculated members while using the Calculated
Member Builder. I don't want to actually save calculated members just
for a string or to use NULL. Basically, I would like to paste that
entire statement below into the Calculated Member Builder and store
that as my new calculated member, but it's giving me an error because
it doesn't seem to like the WITH statement.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Sorry for the late reply... in the calculated member all you need to do is copy and paste the calculated member definition from within the single quotes in the WITH clause, ie
"Is Jones"
and
0
for the two calculated members in the query I gave below.

Chris

"David Hwang" wrote:

How do you use the "with..." statement in the Calculated Member
Builder in Analsys Manager? I don't really want to specify any
dimensions in that value expression.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Hi David,

You can use all the standard VBA functions to convert types in calculated members, eg CINT, CSTR etc. As for the IIF statement, strictly speaking it can only return either two strings or two numeric values, but there is a way round this by getting the IIF statement to return the values of two calculated measures. Here's an example that shows everything in action:

WITH
MEMBER MEASURES.TRUERESULT AS '"Is Jones"'
MEMBER MEASURES.FALSERESULT AS '0'
MEMBER MEASURES.COMPARE AS
'IIF(VBA!CSTR(STORE.CURRENTMEMBER.PROPERTIES("Stor e Manager"))="Jones", MEASURES.TRUERESULT, MEASURES.FALSERESULT)'
SELECT {MEASURES.COMPARE} ON 0,
STORE.[STORE NAME].MEMBERS ON 1
FROM SALES

HTH,

Chris

"David Hwang" wrote:

Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David



Reply With Quote
  #10  
Old   
David Hwang
 
Posts: n/a

Default Re: Converting Data Types in Calculated Members - 06-17-2004 , 02:16 PM



Actually, you answered my question. I didn't want to have to save
three different calculated members on the server. I was hoping to
save only one calculated member on the server that used a WITH clause
to create two temporary calculated members within it's value
expression. But I guess it's not possible.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Quote:
Hi David,

I'm not sure what exactly you want to do, but certainly a WITH clause can only be used with an MDX SELECT statement. The query below would translate to three different calculated members, each created separately, on the server.

Regards,

Chris

"David Hwang" wrote:

Actually, I meant is it still possible to use a WITH clause to
dynamically generate new calculated members while using the Calculated
Member Builder. I don't want to actually save calculated members just
for a string or to use NULL. Basically, I would like to paste that
entire statement below into the Calculated Member Builder and store
that as my new calculated member, but it's giving me an error because
it doesn't seem to like the WITH statement.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Sorry for the late reply... in the calculated member all you need to do is copy and paste the calculated member definition from within the single quotes in the WITH clause, ie
"Is Jones"
and
0
for the two calculated members in the query I gave below.

Chris

"David Hwang" wrote:

How do you use the "with..." statement in the Calculated Member
Builder in Analsys Manager? I don't really want to specify any
dimensions in that value expression.

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> wrote

Hi David,

You can use all the standard VBA functions to convert types in calculated members, eg CINT, CSTR etc. As for the IIF statement, strictly speaking it can only return either two strings or two numeric values, but there is a way round this by getting the IIF statement to return the values of two calculated measures. Here's an example that shows everything in action:

WITH
MEMBER MEASURES.TRUERESULT AS '"Is Jones"'
MEMBER MEASURES.FALSERESULT AS '0'
MEMBER MEASURES.COMPARE AS
'IIF(VBA!CSTR(STORE.CURRENTMEMBER.PROPERTIES("Stor e Manager"))="Jones", MEASURES.TRUERESULT, MEASURES.FALSERESULT)'
SELECT {MEASURES.COMPARE} ON 0,
STORE.[STORE NAME].MEMBERS ON 1
FROM SALES

HTH,

Chris

"David Hwang" wrote:

Does anyone know if it's possible to convert a numeric to a string?
Or have an iif statement that returns either a numeric or a string?
Thanks for any help.

David



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.