Tuesday, March 20, 2012

Retrieving Most recent transaction date

Hi,

I have a fact table containing the transaction code and date on a daily basis. I need to find out for a particular account the most recent date when a particular transaction 'abc' was received. I need to find out most recent dates for other such transactions as well to be displayed on one single report. Basically I would need something like:

ABC Date - Most recent date when 'ABC' transaction was sent

XYZ Date - Most recent date when 'XYZ' transaction was sent. ........

I thought of using the filter available on the cube browser, but if I use filter and use the '=' operator I can only specify one transaction code. But I need dates for different transaction codes.

Any thoughts on this would be greatly appreciated.

Thanks.

Here's a sample Adventure Works query, which returns the last order date for each Promotion listed:

>>

With

Member [Measures].[LastDate] as

Tail(NonEmpty([Date].[Date].[Date].Members,

{[Measures].[Order Quantity]})).Item(0).MemberValue

select

{[Measures].[Order Quantity],

[Measures].[LastDate]} on 0,

Non Empty [Promotion].[Promotion].[Promotion].Members on 1

from [Adventure Works]

-

Order Quantity LastDate
No Discount 238,806 7/31/2004
Volume Discount 11 to 14 18,181 6/30/2004
Volume Discount 15 to 24 10,713 6/1/2004
Volume Discount 25 to 40 2,321 6/1/2004
Volume Discount 41 to 60 85 4/1/2004
Mountain-100 Clearance Sale 456 6/1/2002
Sport Helmet Discount-2002 492 7/1/2002
Road-650 Overstock 304 8/1/2002
Sport Helmet Discount-2003 680 7/1/2003
Touring-3000 Promotion 1,581 9/28/2003
Touring-1000 Promotion 775 9/23/2003
Mountain-500 Silver Clearance Sale 382 6/1/2004

>>

No comments:

Post a Comment