dbTalk Databases Forums  

Return the last Date of a measure

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


Discuss Return the last Date of a measure in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kaisa M. Lindahl
 
Posts: n/a

Default Return the last Date of a measure - 12-23-2005 , 07:00 AM






The heading may be a bit cryptic, but what I need to do is to return the
last date for a measure. I need to see on what date an employee registered
an invoice.
I've tried using Tail, bottomcount and other functions, but I usually end up
with the value of the measure, not the value of the date.

I have a Date dimension, broken into Year, Month and Day. I also have a
Period dimension, broken into Year, Half year, quarter and month.

This query returns the totals for all days that match month in Period, and
the Day, Month and Year for the dates:

select Tail(Filter([Period].[Month].members,(NOT IsEmpty([Measures].[Total
Hours])))) on columns,
non empty crossjoin({[Employee].&[1005]}, order([Date].[Day].members,
[Date].currentmember.name, desc)) on rows
from [MyCube]

Is there a way to get it to return the UniqueName of the Date members, and
just have it return the first row?

Kaisa M. Lindahl



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

Default Re: Return the last Date of a measure - 12-23-2005 , 07:58 PM






Maybe something like this will suffice?

Quote:
With Member [Measures].[DateName] as
'[Date].CurrentMember.UniqueName'

select {[Measures].[DateName]} on columns
from [MyCube]
where (Tail(NonEmptyCrossJoin([Date].[Day].Members,
{[Employee].&[1005]},
{[Measures].[Total Hours]}, 1)).Item(0))
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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


Reply With Quote
  #3  
Old   
Kaisa M. Lindahl
 
Posts: n/a

Default Re: Return the last Date of a measure - 01-02-2006 , 03:56 AM



Works like a charm, Puri!
Thanks a lot, once again.

Kaisa M. Lindahl

"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote

Quote:
Maybe something like this will suffice?


With Member [Measures].[DateName] as
'[Date].CurrentMember.UniqueName'

select {[Measures].[DateName]} on columns
from [MyCube]
where (Tail(NonEmptyCrossJoin([Date].[Day].Members,
{[Employee].&[1005]},
{[Measures].[Total Hours]}, 1)).Item(0))



- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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



Reply With Quote
  #4  
Old   
Kaisa M. Lindahl
 
Posts: n/a

Default Return the last Date of a measure for several levels of a dimension - 02-03-2006 , 05:08 AM



THis is an update of an old message.
I need to get the last dates of a measure for several levels in a dimension.
I need to return the last date for all emplyees in an office. The mdx query
that Deepak Puri suggested (below) returns the date for the first employee,
and shows this date for all employees in that office. How can I make it
check for each employee?

The dimension looks like this:
[All]
[Office]
[Employee]

All help appreciated!!!

Kaisa M: Lindahl



"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote

Quote:
Maybe something like this will suffice?


With Member [Measures].[DateName] as
'[Date].CurrentMember.UniqueName'

select {[Measures].[DateName]} on columns
from [MyCube]
where (Tail(NonEmptyCrossJoin([Date].[Day].Members,
{[Employee].&[1005]},
{[Measures].[Total Hours]}, 1)).Item(0))



- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** 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.