dbTalk Databases Forums  

Last Status MDX

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


Discuss Last Status MDX in the microsoft.public.sqlserver.olap forum.



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

Default Last Status MDX - 11-17-2005 , 10:10 AM






Hi

I have 2 dimensions Person and Answer with two levels "Field" and lower
level "Name".
Now with the below MDX query i get the output

Person Answer
__________________________
Kimberly Accepted
Kimberly Declined
Tom Enrolled
Kevin NotInterested

MDX Query
___________
with
set [FinalSet] as 'NonEmptyCrossJoin(except({[Person].[Name].Members},
({[Person].[All Person]})), [Answer].[Name].members,
{[Question].[DMStatus]}, 2)'

Select {[FinalSet]} on rows,
{[Measures].[Encounter]} on columns
from DM_Answer
WHERE ([Question].&[DMStatus])


I want the Last Answer for that person
The output should be

Person Answer
__________________________
Kimberly Declined (This is the lamost recent answer)
Tom Enrolled
Kevin NotInterested

I tried lot of options like LastChild, Closingperiod but all in vain.

Please help

Thanks in advance

Milind


Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: Last Status MDX - 11-17-2005 , 05:07 PM






I don't really understand the logic of what you are trying to do, it
seems strange that you are looking for the "Last" of something, but
there is no mention of a time dimension.

But that concern aside, you could try something like the following,
using the tail function and a second nested crossjoin. I have not been
able to test this so I hope there are no syntax errors in there.

I have broken out my change so that you can see it easier.

Quote:
WITH

SET [FinalSet] as 'NonEmptyCrossJoin(except({[Person].[Name].Members},
({[Person].[All Person]})),

TAIL(NonEmptyCrossJoin([Answer].[Name].members,{Person.CurrentMember},
{[Question].[DMStatus]}, 1))

)'

Select {[FinalSet]} on rows,
{[Measures].[Encounter]} on columns
from DM_Answer
WHERE ([Question].&[DMStatus])
Quote:
--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <1132243859.351157.260150 (AT) g43g2000cwa (DOT) googlegroups.com>,
milind.bhabal (AT) gmail (DOT) com says...
Quote:
Hi

I have 2 dimensions Person and Answer with two levels "Field" and lower
level "Name".
Now with the below MDX query i get the output

Person Answer
__________________________
Kimberly Accepted
Kimberly Declined
Tom Enrolled
Kevin NotInterested

MDX Query
___________
with
set [FinalSet] as 'NonEmptyCrossJoin(except({[Person].[Name].Members},
({[Person].[All Person]})), [Answer].[Name].members,
{[Question].[DMStatus]}, 2)'

Select {[FinalSet]} on rows,
{[Measures].[Encounter]} on columns
from DM_Answer
WHERE ([Question].&[DMStatus])


I want the Last Answer for that person
The output should be

Person Answer
__________________________
Kimberly Declined (This is the lamost recent answer)
Tom Enrolled
Kevin NotInterested

I tried lot of options like LastChild, Closingperiod but all in vain.

Please help

Thanks in advance

Milind




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

Default Re: Last Status MDX - 11-17-2005 , 05:38 PM



Thanks Darren for the response.

Sorry, I do have a time dimension called [ModifiedTime] with levels
[Year], [Month], [Actual Date] in my MDX ( Actually, it got deleted
while I was removing all the unnecessary dimensions for simplicity).

I dont want to show the ModifiedTime in the output but the Answer above
is the "recent" ModifiedDate for that person.

Sorry for the confusion.

Milind


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

Default Re: Last Status MDX - 11-17-2005 , 08:32 PM



To take [ModifiedTime] dimension into account, try this:

Quote:
With
Set [FinalSet] as
'Generate([Person].[Name].Members,
Extract(Tail(NonEmptyCrossJoin(
{[Person].CurrentMember},
[ModifiedTime].[Actual Date].Members,
[Answer].[Name].Members)),
[Person], [Answer]))'

Select {[FinalSet]} on rows,
{[Measures].[Encounter]} on columns
from DM_Answer
WHERE ([Question].&[DMStatus])
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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


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

Default Re: Last Status MDX - 11-18-2005 , 12:25 PM



Hi Deepak

I tried the above solution but it simply hangs for a long time in the
MDX Sample app.
If I remove "Generate" in the above MDX, the output is one line

Person Answer Encounter
_________ __________ _________
All Person DisEnrolled 15

Any ideas? Thanks for responding.

thanks

Milind


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

Default Re: Last Status MDX - 11-19-2005 , 02:59 AM



Hi Milind,


I created a similar query for Foodmart Sales, where the hanging problem
occurs when the set of persons in Generate is large (about 10,000 total
for Foodmart). One way around this is to work on smaller subsets of
persons, using nested Generate(). In the case of Foodmart Sales, the
following query starts with cities (< 100 with data), then processes all
Customer names under each city in turn:

Quote:
With Set [TestExtract] as
'Generate(NonEmptyCrossJoin(
[Customers].[City].Members),
Generate(NonEmptyCrossJoin(
[Customers].Children),
Extract(Tail(NonEmptyCrossJoin(
{[Customers].CurrentMember},
[Time].[Month].Members,
[Promotions].[Promotion Name].Members)),
[Customers], [Promotions])))'

Select {[Measures].[Unit Sales]} on columns,
[TestExtract] on rows
from Sales
where [Product].[All Products].[Food]
Quote:

In your case, it sounds like you have a [Field] level above [Name] that
might work, depending on the number of Fields, and Names under each one,
in the [Person] dimension:

Quote:
With
Set [FinalSet] as
'Generate(NonEmptyCrossJoin(
[Person].[Field].Members),
Generate(NonEmptyCrossJoin(
[Person].Children),
Extract(Tail(NonEmptyCrossJoin(
{[Person].CurrentMember},
[ModifiedTime].[Actual Date].Members,
[Answer].[Name].Members)),
[Person], [Answer])))'

Select {[FinalSet]} on rows,
{[Measures].[Encounter]} on columns
from DM_Answer
WHERE ([Question].&[DMStatus])
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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


Reply With Quote
  #7  
Old   
Milind
 
Posts: n/a

Default Re: Last Status MDX - 11-22-2005 , 02:47 PM



Thanks Deepak! It worked.


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.