dbTalk Databases Forums  

Aging question..

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


Discuss Aging question.. in the microsoft.public.sqlserver.olap forum.



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

Default Aging question.. - 09-15-2005 , 12:33 AM






I found this code on www.databasejournal.com and it looks like it will do
what I want. However this code ages from 12/31/1997. What I need it to do,
is age from the currently selected member in the cube.

This code is currently constructing a shared dimension.
Any ideas?

IIF(DateDiff('d', "time_by_day"."the_date", '12/31/1997')< 30,
29,IIF(DateDiff('d', "time_by_day"."the_date", '12/31/1997')>= 30 AND
DateDiff('d',"time_by_day"."the_date", '12/31/1997')<= 60, 60,
IIF(DateDiff('d',"time_by_day"."the_date", '12/31/1997')>= 61 AND
DateDiff('d',"time_by_day"."the_date", '12/31/1997')<= 90, 90,
IIF(DateDiff('d',"time_by_day"."the_date", '12/31/1997')>= 91 AND
DateDiff('d',"time_by_day"."the_date", '12/31/1997')<= 120, 120, 999))))

Clint



Reply With Quote
  #2  
Old   
SQL McOLAP
 
Posts: n/a

Default RE: Aging question.. - 09-15-2005 , 09:07 AM






Hi Clint -

The thing to do is to get the name of the time currentmember, and then in
another calc member convert it to a date so datediff can work. As long as
your member names for your day members are something that can be converted by
a cdate(), you should be OK.

Something like:

with member [measures].[CurrTimeName] as '[Time].CurrentMember.Name'

member [measures].[DaysDiff] as
'DateDiff("d",CDate([measures].[CurrTimeName]), Now())', solve_order = 10

member [measures].[Age] as 'IIF([measures].[DaysDiff] > 30,30, etc...)'
solve_order = 20

The above example will get the difference between the selected time member
and today.

You can combine these steps if you like, I just thought splitting them out
would make it easier to understand.

Good luck.

- Phil


"AshVsAOD" wrote:

Quote:
I found this code on www.databasejournal.com and it looks like it will do
what I want. However this code ages from 12/31/1997. What I need it to do,
is age from the currently selected member in the cube.

This code is currently constructing a shared dimension.
Any ideas?

IIF(DateDiff('d', "time_by_day"."the_date", '12/31/1997')< 30,
29,IIF(DateDiff('d', "time_by_day"."the_date", '12/31/1997')>= 30 AND
DateDiff('d',"time_by_day"."the_date", '12/31/1997')<= 60, 60,
IIF(DateDiff('d',"time_by_day"."the_date", '12/31/1997')>= 61 AND
DateDiff('d',"time_by_day"."the_date", '12/31/1997')<= 90, 90,
IIF(DateDiff('d',"time_by_day"."the_date", '12/31/1997')>= 91 AND
DateDiff('d',"time_by_day"."the_date", '12/31/1997')<= 120, 120, 999))))

Clint




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

Default Re: Aging question.. - 09-15-2005 , 05:09 PM



Ah...

Once again, you solve my problem. Thanks!

That makes sense.
"SQL McOLAP" <SQLMcOLAP (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi Clint -

The thing to do is to get the name of the time currentmember, and then in
another calc member convert it to a date so datediff can work. As long as
your member names for your day members are something that can be converted
by
a cdate(), you should be OK.

Something like:

with member [measures].[CurrTimeName] as '[Time].CurrentMember.Name'

member [measures].[DaysDiff] as
'DateDiff("d",CDate([measures].[CurrTimeName]), Now())', solve_order = 10

member [measures].[Age] as 'IIF([measures].[DaysDiff] > 30,30, etc...)'
solve_order = 20

The above example will get the difference between the selected time member
and today.

You can combine these steps if you like, I just thought splitting them out
would make it easier to understand.

Good luck.

- Phil


"AshVsAOD" wrote:

I found this code on www.databasejournal.com and it looks like it will
do
what I want. However this code ages from 12/31/1997. What I need it to
do,
is age from the currently selected member in the cube.

This code is currently constructing a shared dimension.
Any ideas?

IIF(DateDiff('d', "time_by_day"."the_date", '12/31/1997')< 30,
29,IIF(DateDiff('d', "time_by_day"."the_date", '12/31/1997')>= 30 AND
DateDiff('d',"time_by_day"."the_date", '12/31/1997')<= 60, 60,
IIF(DateDiff('d',"time_by_day"."the_date", '12/31/1997')>= 61 AND
DateDiff('d',"time_by_day"."the_date", '12/31/1997')<= 90, 90,
IIF(DateDiff('d',"time_by_day"."the_date", '12/31/1997')>= 91 AND
DateDiff('d',"time_by_day"."the_date", '12/31/1997')<= 120, 120, 999))))

Clint






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.