dbTalk Databases Forums  

Calculation syntax error

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


Discuss Calculation syntax error in the microsoft.public.sqlserver.olap forum.



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

Default Calculation syntax error - 07-26-2004 , 07:40 AM






Hi there

if([Store].currentmember.name = "Store Name", null,
[measures].[Price])

In this sample script I want to say if the level is "Store
Name", calculate Price ...but I get a syntax error, how
would I can I fix it?

Granville


Reply With Quote
  #2  
Old   
Olivier Matrat
 
Posts: n/a

Default Re: Calculation syntax error - 07-26-2004 , 10:03 AM






Hi

Try IIF() instead of IF() and the syntax should be fine.The only trick you
must be aware of using the IIF() function, is that it should return either
two strings, or to numeric values, but not a mix of both.

Now if this is the LEVEL name that you want to test the first argument would
read [Store].CurrentMember.Level.Name.

Also keep in mind that it is often more efficient and easier to maintain no
to rely on the object's names (because they can vary over time).

Here you could for instance use the .Ordinal method instead of .Name to get
the 0-based number of the level within the hierarchy. Also, you could use
the IS operator instead of = to test the object itself, not it's properties.

Regards

Olivier.


"Granville" <granville (AT) ananzi (DOT) co.za> wrote

Quote:
Hi there

if([Store].currentmember.name = "Store Name", null,
[measures].[Price])

In this sample script I want to say if the level is "Store
Name", calculate Price ...but I get a syntax error, how
would I can I fix it?

Granville




Reply With Quote
  #3  
Old   
patrick.vercoutter@jt-int.com
 
Posts: n/a

Default Re: Calculation syntax error - 07-28-2004 , 01:25 PM



Should be Iif instead of If ?




************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...

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.