![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, i'm in trouble with the following mdx issue... I've a time dimension with level Year, Qtr, Month and Days and two measures "Sales" and "Receivables" The fact table is something like that: TimeID Sales Receivables 20051109 10000 30000 20051108 10000 11000 20051104 12000 10000 20051101 10000 0 My goal is to sum backwards in time to calculate how many days are necessary to have Sales >= Receivables For example in 20051109 the result is 5 (10000+10000+12000 > 30000). "20051109" must be considered as a "current member" because it's selected by users using the dimension Thanks for your help! |
#3
| |||
| |||
|

|
here is an example you might be able to look at, sorry that it's NOT based on FoodMart 2000 but another example db i had from reference book i have: /* COUNTING BACKWARDS IN TIME uses waremart 2000 */ with SET [Week Set] as '{ OpeningPeriod([Time].[ByWeek].[Week],Head([Time].[ByWeek].[Week].Members,1).Item(0).Item(0) ) : ClosingPeriod([Time].[ByWeek].[Week], Tail([Time].[ByWeek].[Week].Members,1).Item(0).Item(0)) }' member [Measures].[Accum New Count] as 'Sum( { [Time].[ByWeek].CurrentMember : ClosingPeriod([Time].[ByWeek].[Week], Tail([Time].[ByWeek].[Week].Members,1).Item(0).Item(0))}, [Measures].[Count Added] )' SET [Times Until Sum] as 'Filter( {[Week Set] }, [Measures].[Accum New Count] <= 50000000 )' select { [Measures].[Accum New Count] } on columns, { [Times Until Sum] } on rows from Inventory "Gianluca" wrote: Hi all, i'm in trouble with the following mdx issue... I've a time dimension with level Year, Qtr, Month and Days and two measures "Sales" and "Receivables" The fact table is something like that: TimeID Sales Receivables 20051109 10000 30000 20051108 10000 11000 20051104 12000 10000 20051101 10000 0 My goal is to sum backwards in time to calculate how many days are necessary to have Sales >= Receivables |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Hi Darren, Mike and many thanks for your reply (sorry if the first post was with the name of my colleague Gianluca). Darren, i've choosen your approach with just some changes to use days instead of month and to manage cross-period days (end of month, quarter or year). I will not use the result member because what i need it seems to be the offset (as a result i obtain a difference betwwen days) I will test again but i think final expression will be Count( Filter( Union( {DESCENDANTS([Time].[Standard].CurrentMember, [Time].[Standard].[Day]).item(DESCENDANTS([Time].[Standard].CurrentMember, [Time].[Standard].[Day]).count-1).item(0)} as cDay , --[Time].[Standard].[Day].&[-1].NextMember DESCENDANTS([Time].[Standard].CurrentMember, [Time].[Standard].[Day]).item(DESCENDANTS([Time].[Standard].CurrentMember, [Time].[Standard].[Day]).count-1).item(0).lag(730) : DESCENDANTS([Time].[Standard].CurrentMember, [Time].[Standard].[Day]).item(DESCENDANTS([Time].[Standard].CurrentMember, [Time].[Standard].[Day]).count-1).item(0) ) , sum(cDay.item(0) ESCENDANTS([Time].[Standard].CurrentMember,[Time].[Standard].[Day]).item(DESCENDANTS([Time].[Standard].CurrentMember, [Time].[Standard].[Day]).count-1).item(0), [Measures].[Vendite]) sum(cDay, [Measures].[Crediti]) ) ) Now my main problem is query performance. There are no so many rows in fact table but this formula evaluate a measure for each day and it has very long response time. As you can see i've tried to start 2 years before the current time member and it seems to be quicker but if user makes a different selection (ie not country list but customers), the query hangs... Is it possible to count starting from the end (the time current member) and stop when a certain condition is met? maybe using recursive calculated members? Many thanks for your help!!! |
![]() |
| Thread Tools | |
| Display Modes | |
| |