dbTalk Databases Forums  

Using function to add member to a set

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


Discuss Using function to add member to a set in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Raj C.
 
Posts: n/a

Default Using function to add member to a set - 08-26-2004 , 03:55 PM






Hi,
I have created the following MDX query that queries the
Foodmart 2000 Sales Cube:

WITH
SET [Test1] as' ({[Gender].[All Gender].[F],[Gender].[All
Gender].[M],[Gender].[All Gender].[F]}*{[Marital
Status].members})'
SELECT
{[Measures].[Unit Sales]} on COLUMNS,
{[Test1]} on ROWS
FROM [Sales]

I would like to add the member "[Gender].[All Gender]"
to the set [Test1] set WITHOUT ACTUALLY EDITING/MODIFYING
the set notation in the with clause. This should require
use of a some MDX function.

Please note that:

1. We know prior to executing query what dimensions are
included in the set [Test1] -- Gender and Marital Status

2. We need to preserve the repeating member ("[Gender].
[All Gender].[F]") in the Gender dimension.

We tried using the union and extract functions (see
syntax below) but we were unable to preserve the
repeating member present in the original query:

WITH
SET [Test1] as' ({[Gender].[All Gender].[F],[Gender].[All
Gender].[M],[Gender].[All Gender].[F]}*{[Marital
Status].members})'
SELECT
{[Measures].[Unit Sales]} on COLUMNS,
(Union({Extract({[Test1]},[Gender])},{[Gender].[All
Gender]}) * {Extract({[Test1]},[Marital Status])}) on ROWS
FROM [Sales]

ANY HELP ON THIS MATTER WOULD BE GREATLY APPRECIATED!!

Thanks,
Raj C.




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

Default Re: Using function to add member to a set - 08-27-2004 , 12:42 AM






After some trial and error, this version works. However, it is based on
the assumption that the first member of [Marital Status] in [Test1] is
not repeated:

Quote:
WITH
SET [Test1] as' ({[Gender].[All Gender].[F],
[Gender].[All Gender].[M],[Gender].[All Gender].[F]}
*{[Marital Status].members})'
SELECT
{[Measures].[Unit Sales]} on COLUMNS,
{Union(Generate(Filter([Test1],
[Marital Status].CurrentMember is [Test1].Item(0).Item(1)),
{[Gender].CurrentMember}, ALL),
{[Gender].[All Gender]}, ALL)
* Extract([Test1], [Marital Status])}
on ROWS
FROM [Sales]
Quote:

- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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.