all groups > sql server data warehouse > november 2005 >
You're in the

sql server data warehouse

group:

Recency, time since last sale



Recency, time since last sale Jacob_I
11/11/2005 3:32:05 AM
sql server data warehouse: Hi,

I'm trying to implement a recency measure for my individual customers,
telling me how many days have gone by since the last purchase of a customer.
I would like it to go something like this:

with member time.week.last_purchase_date as
'Tail(Filter([Time].[Week].[Date].members, Not
IsEmpty(([Measures].[Quantity],[Customers].[Geography].CurrentMember)))).Item(0).Item(0).uniquename '

member measures.days_since_last_purchase as
'Datediff(time.week.lastpurchasedate : [Time].[Week].Currentmember)'

Of course there is no Datediff in MDX, but how can I construct the syntax to
meet my requirements?

RE: Recency, time since last sale mike
11/11/2005 11:57:12 AM
have you tried using vba functions? DateDiff() and CDate() ??

[quoted text, click to view]
RE: Recency, time since last sale Jacob_I
11/12/2005 2:54:02 AM
Hi Mike

Actually, I didn't think about that at all. I'll try that and post my
findings.

[quoted text, click to view]
Re: Recency, time since last sale MC
11/14/2005 10:12:04 AM
As far as the MDX goes, you could substract index positions of two dates.
It would mean that you find index position of last purchase date in the date
dimension and then find index position of 'today' or some other date...


MC


[quoted text, click to view]

Re: Recency, time since last sale Jacob_I
11/16/2005 4:01:06 AM
Thanks a lot Mike & MC. I've gotten the datediff stuff working beautifully
thansk to you valuable advice. But I also need it to be time-sensitive, so
that when I use the calc member:

'Tail(Filter([Time].[Week].[Date].members, Not
IsEmpty(([Measures].[Quantity],[Customers].[Geography].CurrentMember)))).Item(0).Item(0).uniquename '

...the [Time].[Week].[Date].members is replaced by a set of members that
looks something like ([time].[week].(All):[Time].[week].Currentmember) ie. it
returns all members from beginning of time until time.currentmember.

Can this be done? Maybe it's woth a new thread?

Thanks in advance!

Regards, Jacob


Re: Recency, time since last sale Darren Gosbell
11/17/2005 12:00:00 AM
In article <E88FB2ED-46C5-4DDC-B4A6-C1222C611986@microsoft.com>,
JacobI@discussions.microsoft.com says...
[quoted text, click to view]

You could use something like

[time].[week].members.item(0):[Time].[week].Currentmember

Or, to be completely idependant of which level you are on:

[time].CurrentMember.Level.Members.item(0):[Time].[week].Currentmember

HTH

--
Regards
Darren Gosbell [MCSD]
Re: Recency, time since last sale prady
12/5/2005 12:59:02 AM
hi Jacob,
I am also facing a similar problem with the datediff. Could you share on how
you overcame the prob on datediff.
Thanks in advance
Prady

[quoted text, click to view]
Re: Recency, time since last sale Jacob_I
12/5/2005 1:46:02 AM
Hi Prady,

Although I don't have the code right here, I can illustrate the layout of my
final query:

// This part gives me the date of last puchase and case it to DATE type
CDate(Tail(Filter({<Configure a date member range>}, Not
IsEmpty(([Measures].[Quantity],[Customers].[Geography].CurrentMember)))).Item(0).Item(0).uniquename) -

// Minus the currentdate
Now()

(end)

The date member range can be anything from a date range in a named set to
something that changes with the time.currentmember, eg.
{time.currentmember.lag(182):time.currentmember} which if a date-level will
give you a range of half a year. As this query if quite heavy for at large
customer dimension it's rather sensible to have a small date member range.

The minus part can also be Cdate(time.currentmember.name) which (depending
on your data level member formatting) also will give you a DATE type result
to minus with the first part.

HTH

Jacob_I



AddThis Social Bookmark Button