dbTalk Databases Forums  

Eliminating zero values

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


Discuss Eliminating zero values in the microsoft.public.sqlserver.olap forum.



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

Default Eliminating zero values - 07-06-2006 , 10:03 AM






I have a cube with a measure 'Remaining Step Count' and a measure
Quantity.

The Remaining Step Count field is always non null and can be zero or
any other value.

The Quantity field is always 1.

In a test case covering a period of time, there are actually 283
remaining step count values that are > 0; 1420 are equal to zero.

I am trying to define a calculated measure in Analysis Service Manager
for this cube that will count the number of non zero values. In this
test case, I expect 283 as the result.

I tried this as the calculated measure but it always returns 1703 - the
total of zero and non zero values, not just the count of those with non
zero 'Remaining Step Counts'

IIF ( [Measures].[Remaining Step Count] > 0,[Measures].[Quantity],0)

I saw this suggested somewhere but it does the same thing, returning
1703:

IIF ( [Measures].[Remaining Step Count] = 0,NULL,[Measures].[Quantity])

I also tried this but it always returns 1:

IIF ( [Measures].[Remaining Step Count] = 0,NULL,1)

Any help in defining this calculated measure properly would be
appreciated.


Reply With Quote
  #2  
Old   
Jéjé
 
Posts: n/a

Default Re: Eliminating zero values - 07-06-2006 , 12:35 PM






this formula:
IIF ( [Measures].[Remaining Step Count] = 0,NULL,[Measures].[Quantity])

is evaluated in the current query context, NOT at the leaf level of the
cube.
if you want to apply this at the leaf level, create a new measure (not a
calculated one) based on this SQL statement:
case when Remaining_Step_Count_Column = 0 then null else Quantity_Column end

other option...
if you have a dimension "Step" in the cube, then you can use an MDX formula
like:
aggregate([Measures].[Quantity], Step.&[1]:Step.lastchild)

(you'll aggregate the quantities only for step starting at 1 to the last
member; syntax to validate)


"Tiger Tail" <Larry_Uzzel (AT) hotmail (DOT) com> wrote

Quote:
I have a cube with a measure 'Remaining Step Count' and a measure
Quantity.

The Remaining Step Count field is always non null and can be zero or
any other value.

The Quantity field is always 1.

In a test case covering a period of time, there are actually 283
remaining step count values that are > 0; 1420 are equal to zero.

I am trying to define a calculated measure in Analysis Service Manager
for this cube that will count the number of non zero values. In this
test case, I expect 283 as the result.

I tried this as the calculated measure but it always returns 1703 - the
total of zero and non zero values, not just the count of those with non
zero 'Remaining Step Counts'

IIF ( [Measures].[Remaining Step Count] > 0,[Measures].[Quantity],0)

I saw this suggested somewhere but it does the same thing, returning
1703:

IIF ( [Measures].[Remaining Step Count] = 0,NULL,[Measures].[Quantity])

I also tried this but it always returns 1:

IIF ( [Measures].[Remaining Step Count] = 0,NULL,1)

Any help in defining this calculated measure properly would be
appreciated.




Reply With Quote
  #3  
Old   
Tiger Tail
 
Posts: n/a

Default Re: Eliminating zero values - 07-06-2006 , 05:47 PM



Thanks for the assist.

I defined 2 new measures (not calculated) - one that would properly sum
the values and another that would properly count the values.

I was then able to do a calculated measure using them and it works
fine.



Jéjé wrote:
Quote:
this formula:
IIF ( [Measures].[Remaining Step Count] = 0,NULL,[Measures].[Quantity])

is evaluated in the current query context, NOT at the leaf level of the
cube.
if you want to apply this at the leaf level, create a new measure (not a
calculated one) based on this SQL statement:
case when Remaining_Step_Count_Column = 0 then null else Quantity_Column end

other option...
if you have a dimension "Step" in the cube, then you can use an MDX formula
like:
aggregate([Measures].[Quantity], Step.&[1]:Step.lastchild)

(you'll aggregate the quantities only for step starting at 1 to the last
member; syntax to validate)


"Tiger Tail" <Larry_Uzzel (AT) hotmail (DOT) com> wrote in message
news:1152198196.838494.36310 (AT) a14g2000cwb (DOT) googlegroups.com...
I have a cube with a measure 'Remaining Step Count' and a measure
Quantity.

The Remaining Step Count field is always non null and can be zero or
any other value.

The Quantity field is always 1.

In a test case covering a period of time, there are actually 283
remaining step count values that are > 0; 1420 are equal to zero.

I am trying to define a calculated measure in Analysis Service Manager
for this cube that will count the number of non zero values. In this
test case, I expect 283 as the result.

I tried this as the calculated measure but it always returns 1703 - the
total of zero and non zero values, not just the count of those with non
zero 'Remaining Step Counts'

IIF ( [Measures].[Remaining Step Count] > 0,[Measures].[Quantity],0)

I saw this suggested somewhere but it does the same thing, returning
1703:

IIF ( [Measures].[Remaining Step Count] = 0,NULL,[Measures].[Quantity])

I also tried this but it always returns 1:

IIF ( [Measures].[Remaining Step Count] = 0,NULL,1)

Any help in defining this calculated measure properly would be
appreciated.



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.