dbTalk Databases Forums  

How to get Last Visit to the customer

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


Discuss How to get Last Visit to the customer in the microsoft.public.sqlserver.olap forum.



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

Default How to get Last Visit to the customer - 08-26-2004 , 07:10 AM






Hi,
I have the granularity in fact table as Activity,Customer,Time
Certain defined activities are created which are done at the customer
Store like checking the retaiol Audit which have measures like count
of Product,Displayed price of the product etc.

I wanted to get the Last visit made to the selected customer as
calculated member in Activity dimension.

This Last visit is the Max date in the Fact table for this customer.

If I select this calculated member stored in the Activity dimension it
should show me all the measures for the selected customer for the Last
visit date done to this customer.

Any help is highly appreciated

regds

Reply With Quote
  #2  
Old   
Prasanna
 
Posts: n/a

Default Required urgently : How to get Last Visit to the customer - 08-28-2004 , 07:09 AM






for the selected customer i need Max timeid from the cube using MDX
i was trying this query

iif([SALES FORCE].CurrentMember.Level.Ordinal=[SALES FORCE].[VISIT TO
CUSTOMER].Ordinal,Max(descendants([Time].[Weekly].currentmember,
[Time].[Weekly].[Date]) , [Time Version].&[1]),Null)


but this gives me the timeid which has max records rather than the Max
timeid

but i want something like this

timeid Customer_id Activity_id unit_sales
====== =========== ========== ===========
1511 1 2 100
1511 1 3 200
1512 1 2 50
1513 1 2 20


I want 1513 to be displayed but the above query gives me 1511

Please help


tawargerip (AT) hotmail (DOT) com (Prasanna) wrote in message news:<d4b0bad7.0408260410.355a76e2 (AT) posting (DOT) google.com>...
Quote:
Hi,
I have the granularity in fact table as Activity,Customer,Time
Certain defined activities are created which are done at the customer
Store like checking the retaiol Audit which have measures like count
of Product,Displayed price of the product etc.

I wanted to get the Last visit made to the selected customer as
calculated member in Activity dimension.

This Last visit is the Max date in the Fact table for this customer.

If I select this calculated member stored in the Activity dimension it
should show me all the measures for the selected customer for the Last
visit date done to this customer.

Any help is highly appreciated

regds

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

Default Re: Required urgently : How to get Last Visit to the customer - 08-28-2004 , 10:24 PM



How is timeid exposed in the cube - is it a key or member property of a
Time dimension? Max() returns the highest value of the second argument
(numeric expression) over the first argument(set). So, in this case, how
does the expression: [Time Version].&[1] return a timeid value?


- Deepak

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

Reply With Quote
  #4  
Old   
Prasanna
 
Posts: n/a

Default Re: Required urgently : How to get Last Visit to the customer - 08-29-2004 , 05:35 AM



Hi,
[Time Version].&[1] is a dummy record which has value 1 in all the
records in the fact table.
Period is the time dimension and Period_id is the key exposed in cube
as timekey

Appreciate your help

Regards

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

Quote:
How is timeid exposed in the cube - is it a key or member property of a
Time dimension? Max() returns the highest value of the second argument
(numeric expression) over the first argument(set). So, in this case, how
does the expression: [Time Version].&[1] return a timeid value?


- Deepak

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

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

Default Re: Required urgently : How to get Last Visit to the customer - 08-30-2004 , 12:53 AM



Still not sure of all the details, but it looks like your Max() numeric
expression is defaulting to [Unit Sales] (assuming that is the cube's
default measure).

Here's a query for Foodmart Sales that should be similar to what you're
trying - the [MaxTime] measure returns the maximum month key over all
months in which there were sales to the selected customer. In the case
of [Alice Cantrell], sales occurred in Aug, Oct & Dec, so max is 12:

Quote:
With Member [Measures].[TimeKey] as
'StrToValue([Time].CurrentMember.Properties("Key"))'
Member [Measures].[MaxTime] as
'iif([Customers].CurrentMember.Level is [Customers].[Name],
Max(NonEmptyCrossJoin(Descendants([Time].CurrentMember,
[Time].[Month]), {[Customers].CurrentMember}, 1),
[Measures].[TimeKey]),Null)'
Select {[Measures].[MaxTime]} on columns,
{[Time].[1997]} on rows
from Sales
where ([Customers].[All Customers].[USA].[CA].[Altadena].[Alice
Cantrell])
Quote:

- Deepak

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


Reply With Quote
  #6  
Old   
news.west.cox.net
 
Posts: n/a

Default Re: Required urgently : How to get Last Visit to the customer - 09-30-2004 , 01:19 AM





Try combining the TAIL function with non empty crossjoin.

Somrething like (untested)

(TAIL(NonEmptyCrossJoin(descendants([Time].[Weekly].currentmember,
[Time].[Weekly].[Date]) ,{[Time Version]},1),1),[Time Version])

"Prasanna" <tawargerip (AT) hotmail (DOT) com> wrote

Quote:
for the selected customer i need Max timeid from the cube using MDX
i was trying this query

iif([SALES FORCE].CurrentMember.Level.Ordinal=[SALES FORCE].[VISIT TO
CUSTOMER].Ordinal,Max(descendants([Time].[Weekly].currentmember,
[Time].[Weekly].[Date]) , [Time Version].&[1]),Null)


but this gives me the timeid which has max records rather than the Max
timeid

but i want something like this

timeid Customer_id Activity_id unit_sales
====== =========== ========== ===========
1511 1 2 100
1511 1 3 200
1512 1 2 50
1513 1 2 20


I want 1513 to be displayed but the above query gives me 1511

Please help


tawargerip (AT) hotmail (DOT) com (Prasanna) wrote in message
news:<d4b0bad7.0408260410.355a76e2 (AT) posting (DOT) google.com>...
Hi,
I have the granularity in fact table as Activity,Customer,Time
Certain defined activities are created which are done at the customer
Store like checking the retaiol Audit which have measures like count
of Product,Displayed price of the product etc.

I wanted to get the Last visit made to the selected customer as
calculated member in Activity dimension.

This Last visit is the Max date in the Fact table for this customer.

If I select this calculated member stored in the Activity dimension it
should show me all the measures for the selected customer for the Last
visit date done to this customer.

Any help is highly appreciated

regds



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.