dbTalk Databases Forums  

Problem with TopCount and Non Empty

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


Discuss Problem with TopCount and Non Empty in the microsoft.public.sqlserver.olap forum.



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

Default Problem with TopCount and Non Empty - 08-22-2006 , 03:45 PM






The problem is that the query below filters by TopCount before it does
the Non Empty.
There are several rows within the 20 that have a null value for [sales
units]. Null evidently equates to zero, because I have some rows that
have a value of -1 for [sales units] that I don't see unless I set the
TopCount value much higher. (I use TopCount = 20, I get 6 rows; I use
TopCount = 50, I get 12 rows)

I would like to have the Non Empty inside the TopCount, but I haven't
been able to figure out how to do it.


SELECT NON EMPTY { [Measures].[sales units]} ON COLUMNS,
NON EMPTY {
TOPCOUNT (
([Product].[Style Label].[Style Label].ALLMEMBERS)
,20,
[Measures].[sales units])
}
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME
ON ROWS
FROM [MY CUBE]))
WHERE ([Date].[Week End Date].&[2006-01-28T00:00:00]


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

Default Re: Problem with TopCount and Non Empty - 08-22-2006 , 03:54 PM






SELECT NON EMPTY { [Measures].[sales units]} ON COLUMNS,
NON EMPTY {
TOPCOUNT (
([Product].[Style Label].CHILDREN)
,20,
[Measures].[sales units])


}


DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME
ON ROWS
FROM [MY CUBE]))
WHERE ([Date].[Week End Date].&[2006-01-28T00:00:00]
cowznofsky ha escrito:

Quote:
The problem is that the query below filters by TopCount before it does
the Non Empty.
There are several rows within the 20 that have a null value for [sales
units]. Null evidently equates to zero, because I have some rows that
have a value of -1 for [sales units] that I don't see unless I set the
TopCount value much higher. (I use TopCount = 20, I get 6 rows; I use
TopCount = 50, I get 12 rows)

I would like to have the Non Empty inside the TopCount, but I haven't
been able to figure out how to do it.


SELECT NON EMPTY { [Measures].[sales units]} ON COLUMNS,
NON EMPTY {
TOPCOUNT (
([Product].[Style Label].[Style Label].ALLMEMBERS)
,20,
[Measures].[sales units])
}
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME
ON ROWS
FROM [MY CUBE]))
WHERE ([Date].[Week End Date].&[2006-01-28T00:00:00]


Reply With Quote
  #3  
Old   
ZULFIQAR SYED
 
Posts: n/a

Default Re: Problem with TopCount and Non Empty - 08-22-2006 , 08:06 PM



Here is a sample code of NONEMPTY inside of TOPCOUNT based on AS2005
Adventure Works sample.

select
[Measures].[Reseller Sales Amount] on 0,
topcount(
nonempty(
[Promotion].[Promotions].[Promotion]
)
,
3
,
[Measures].[Reseller Sales Amount]
)
on 1
from
[Adventure Works]

HTH..

ZULFIQAR SYED
HTTP://ZULFIQAR.TYPEPAD.COM

cowznofsky wrote:
Quote:
The problem is that the query below filters by TopCount before it does
the Non Empty.
There are several rows within the 20 that have a null value for [sales
units]. Null evidently equates to zero, because I have some rows that
have a value of -1 for [sales units] that I don't see unless I set the
TopCount value much higher. (I use TopCount = 20, I get 6 rows; I use
TopCount = 50, I get 12 rows)

I would like to have the Non Empty inside the TopCount, but I haven't
been able to figure out how to do it.


SELECT NON EMPTY { [Measures].[sales units]} ON COLUMNS,
NON EMPTY {
TOPCOUNT (
([Product].[Style Label].[Style Label].ALLMEMBERS)
,20,
[Measures].[sales units])
}
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME
ON ROWS
FROM [MY CUBE]))
WHERE ([Date].[Week End Date].&[2006-01-28T00:00:00]


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

Default Re: Problem with TopCount and Non Empty - 08-23-2006 , 08:18 AM



Thanks, this one worked for me. It's very confusing that
there is both 'NON EMPTY' and 'NONEMPTY' which are two different
things.


ZULFIQAR SYED wrote:
Quote:
Here is a sample code of NONEMPTY inside of TOPCOUNT based on AS2005
Adventure Works sample.

select
[Measures].[Reseller Sales Amount] on 0,
topcount(
nonempty(
[Promotion].[Promotions].[Promotion]
)
,
3
,
[Measures].[Reseller Sales Amount]
)
on 1
from
[Adventure Works]

HTH..

ZULFIQAR SYED
HTTP://ZULFIQAR.TYPEPAD.COM

cowznofsky wrote:
The problem is that the query below filters by TopCount before it does
the Non Empty.
There are several rows within the 20 that have a null value for [sales
units]. Null evidently equates to zero, because I have some rows that
have a value of -1 for [sales units] that I don't see unless I set the
TopCount value much higher. (I use TopCount = 20, I get 6 rows; I use
TopCount = 50, I get 12 rows)

I would like to have the Non Empty inside the TopCount, but I haven't
been able to figure out how to do it.


SELECT NON EMPTY { [Measures].[sales units]} ON COLUMNS,
NON EMPTY {
TOPCOUNT (
([Product].[Style Label].[Style Label].ALLMEMBERS)
,20,
[Measures].[sales units])
}
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME
ON ROWS
FROM [MY CUBE]))
WHERE ([Date].[Week End Date].&[2006-01-28T00:00:00]


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.