dbTalk Databases Forums  

Filter Function

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


Discuss Filter Function in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kevin R.
 
Posts: n/a

Default Filter Function - 06-02-2005 , 02:38 PM






Hi everyone,

I have the following MDX for FoodMart 2000:

SELECT CROSSJOIN({[Measures].[Unit
Sales]},{FILTER([Time].[1997].[Q3]:[Time].[1998].[Q4],[Measures].[Unit
Sales] <7000)}) ON COLUMNS,
{[Product].[Drink]} ON ROWS FROM [WareHouse and Sales]

The intend here is to only show Unit Sales for [Product].[Drink] for
1997 Q3 and Q4 quarters. However, this MDX returns all 1998 quarters.
The reason being The search condition in the Filter function above
considers [Product].[All Products] member and therefore excludes the
desired 1997 quarters.

I tried to nartow the the Filter search condition to
[Product].CurrentMember as follows but get the same result:

SELECT CROSSJOIN({[Measures].[Unit
Sales]},{FILTER([Time].[1997].[Q3]:[Time].[1998].[Q4],([Product].Current
Member,[Measures].[Unit Sales])<7000)}) ON COLUMNS,
{[Product].[DRINK]} ON ROWS FROM [WareHouse and Sales]

My intend for this query is to filter out those quarters after 1997 Q2
which have Unit Sales of less than 7000. So the resultset should be:

Unit Sales
1997 Q3 1997 Q4
Drink 6065 6661


All help is greatly appreciated,
kr

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Filter Function - 06-02-2005 , 05:56 PM






Assuming that quarters with no data should be excluded, this version of
the query returns the desired results:

Quote:
SELECT NON EMPTY CROSSJOIN({[Measures].[Unit Sales]},
FILTER([Time].[1997].[Q3]:[Time].[1998].[Q4],
([Measures].[Unit Sales],[Product].[Drink]) <7000)) ON COLUMNS,
{[Product].[Drink]} ON ROWS FROM [WareHouse and Sales]
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #3  
Old   
Kevin R.
 
Posts: n/a

Default Re: Filter Function - 06-03-2005 , 12:28 PM



Hi Deepak,

Thanks for your reply. I guess I did not use a good MDX to truely convey
my problem. Please consider the following MDX:

select
{ crossjoin( {[Product].[All Products].children},{[Measures].[Unit
Sales] } )} on rows,
{ crossjoin( { [Store].[All Stores].[USA].children},
{filter(([Time].[1997].[Q1]:[Time].[1998].[Q3]),[Measures].[Unit
Sales]>0) } ) } on columns
from [Warehouse and Sales] WHERE [Promotions].[Big Time Discounts]


Here I get back Q1 and Q4 for all stores while my desired resultset
should look like the following:

OR WA
Q4 Q1
Drink Unit Sales 39.00 32.00
Food Unit Sales 371.00 291.00
Non-Conum Unit Sales 123.00 76.00

Effectively, I want to suppress all zero cells. This seems like a common
and easy problem but I can not get the Filter funciton to behave. Do you
have any ideas?

thx,
kr




*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #4  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Filter Function - 06-03-2005 , 04:43 PM



In AS 2000, there is a distinction between empty and zero valued cells -
I think you wish to eliminate empty, like:

Quote:
select
crossjoin([Product].[All Products].children,
{[Measures].[Unit Sales] }) on rows,
NON EMPTY crossjoin([Store].[All Stores].[USA].children,
{[Time].[1997].[Q1]:[Time].[1998].[Q3]}) on columns
from [Warehouse and Sales]
WHERE [Promotions].[Big Time Discounts]
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #5  
Old   
Kevin R.
 
Posts: n/a

Default Re: Filter Function - 06-03-2005 , 07:10 PM



Deepak,

Thank you. That' what I wanted to do.


*** Sent via Developersdex http://www.developersdex.com ***

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.