dbTalk Databases Forums  

Filtering in a Calculated Measure

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


Discuss Filtering in a Calculated Measure in the microsoft.public.sqlserver.olap forum.



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

Default Filtering in a Calculated Measure - 08-01-2005 , 10:26 AM






I have a calculated measure as follows called Effective Tax Rate.

([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt]

I need to add filtering to the denominator. The pseudocode would look like
this.

([Tax Paid] + [Use tax Accrued]) /
[Merchandise Amt where State (dimension) <> '']

Could someone help me out with the MDX syntax for this?


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

Default RE: Filtering in a Calculated Measure - 08-01-2005 , 12:56 PM






I didn't fully understand your questions, but, I think you mean to use a
construct like this:

IIF (<dimension>.CurrentMember <> 'something' AND [Merchandise Amt] <> 0,
([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt], NULL)

Murthy

"ChrisBusch" wrote:

Quote:
I have a calculated measure as follows called Effective Tax Rate.

([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt]

I need to add filtering to the denominator. The pseudocode would look like
this.

([Tax Paid] + [Use tax Accrued]) /
[Merchandise Amt where State (dimension) <> '']

Could someone help me out with the MDX syntax for this?


Reply With Quote
  #3  
Old   
CBUSCH
 
Posts: n/a

Default RE: Filtering in a Calculated Measure - 08-01-2005 , 04:01 PM



Close, but getting a syntax error. The test is State = ' '

I get invalid token on this...

IIF (State.CurrentMember = ' ' AND [Merchandise Amt] <> 0,
([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt], NULL)



"MurthyJ" wrote:

Quote:
I didn't fully understand your questions, but, I think you mean to use a
construct like this:

IIF (<dimension>.CurrentMember <> 'something' AND [Merchandise Amt] <> 0,
([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt], NULL)

Murthy

"ChrisBusch" wrote:

I have a calculated measure as follows called Effective Tax Rate.

([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt]

I need to add filtering to the denominator. The pseudocode would look like
this.

([Tax Paid] + [Use tax Accrued]) /
[Merchandise Amt where State (dimension) <> '']

Could someone help me out with the MDX syntax for this?


Reply With Quote
  #4  
Old   
MurthyJ
 
Posts: n/a

Default RE: Filtering in a Calculated Measure - 08-02-2005 , 11:20 AM



You can try one of these forms to see which one fits what you need:

State.CurrentMember.UniqueName= "" (notice double quotes, not single quotes)
State.CurrentMember IS NULL

Murthy

"CBUSCH" wrote:

Quote:
Close, but getting a syntax error. The test is State = ' '

I get invalid token on this...

IIF (State.CurrentMember = ' ' AND [Merchandise Amt] <> 0,
([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt], NULL)



"MurthyJ" wrote:

I didn't fully understand your questions, but, I think you mean to use a
construct like this:

IIF (<dimension>.CurrentMember <> 'something' AND [Merchandise Amt] <> 0,
([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt], NULL)

Murthy

"ChrisBusch" wrote:

I have a calculated measure as follows called Effective Tax Rate.

([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt]

I need to add filtering to the denominator. The pseudocode would look like
this.

([Tax Paid] + [Use tax Accrued]) /
[Merchandise Amt where State (dimension) <> '']

Could someone help me out with the MDX syntax for this?


Reply With Quote
  #5  
Old   
CBUSCH
 
Posts: n/a

Default RE: Filtering in a Calculated Measure - 08-02-2005 , 02:43 PM



Got the syntax working, but the test on state is not working.

I tried...

IIF (State.CurrentMember.UniqueName= " ",[Merchandise Amt], NULL)
and...
IIF (State.CurrentMember.UniqueName= "",[Merchandise Amt], NULL)
and...
IIF (State.CurrentMember IS NULL,[Merchandise Amt], NULL)

They all return Merchandise Amt regardless of what value is in State.
I'm not sure what the value in State is blank, empty string, or nulll
The value in the source database is blank (" ")

Thanks for your help with this.





"MurthyJ" wrote:

Quote:
You can try one of these forms to see which one fits what you need:

State.CurrentMember.UniqueName= "" (notice double quotes, not single quotes)
State.CurrentMember IS NULL

Murthy

"CBUSCH" wrote:

Close, but getting a syntax error. The test is State = ' '

I get invalid token on this...

IIF (State.CurrentMember = ' ' AND [Merchandise Amt] <> 0,
([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt], NULL)



"MurthyJ" wrote:

I didn't fully understand your questions, but, I think you mean to use a
construct like this:

IIF (<dimension>.CurrentMember <> 'something' AND [Merchandise Amt] <> 0,
([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt], NULL)

Murthy

"ChrisBusch" wrote:

I have a calculated measure as follows called Effective Tax Rate.

([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt]

I need to add filtering to the denominator. The pseudocode would look like
this.

([Tax Paid] + [Use tax Accrued]) /
[Merchandise Amt where State (dimension) <> '']

Could someone help me out with the MDX syntax for this?


Reply With Quote
  #6  
Old   
MurthyJ
 
Posts: n/a

Default RE: Filtering in a Calculated Measure - 08-02-2005 , 07:13 PM



For uniquename test, you would have to use the preceding level values also
(for instance, [State].[All State].[ ], depending on whatever other levels
you may have). Sorry I might have misled you in my earlier sample.

Use Name instead of UniqueName as in

IIF (State.CurrentMember.Name= " ",[Merchandise Amt], NULL)

Murthy

"CBUSCH" wrote:

Quote:
Got the syntax working, but the test on state is not working.

I tried...

IIF (State.CurrentMember.UniqueName= " ",[Merchandise Amt], NULL)
and...
IIF (State.CurrentMember.UniqueName= "",[Merchandise Amt], NULL)
and...
IIF (State.CurrentMember IS NULL,[Merchandise Amt], NULL)

They all return Merchandise Amt regardless of what value is in State.
I'm not sure what the value in State is blank, empty string, or nulll
The value in the source database is blank (" ")

Thanks for your help with this.





"MurthyJ" wrote:

You can try one of these forms to see which one fits what you need:

State.CurrentMember.UniqueName= "" (notice double quotes, not single quotes)
State.CurrentMember IS NULL

Murthy

"CBUSCH" wrote:

Close, but getting a syntax error. The test is State = ' '

I get invalid token on this...

IIF (State.CurrentMember = ' ' AND [Merchandise Amt] <> 0,
([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt], NULL)



"MurthyJ" wrote:

I didn't fully understand your questions, but, I think you mean to use a
construct like this:

IIF (<dimension>.CurrentMember <> 'something' AND [Merchandise Amt] <> 0,
([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt], NULL)

Murthy

"ChrisBusch" wrote:

I have a calculated measure as follows called Effective Tax Rate.

([Tax Paid] + [Use tax Accrued]) / [Merchandise Amt]

I need to add filtering to the denominator. The pseudocode would look like
this.

([Tax Paid] + [Use tax Accrued]) /
[Merchandise Amt where State (dimension) <> '']

Could someone help me out with the MDX syntax for this?


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.