![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
iif( [Line].CurrentMember is [Line].[All Line], Sum([Line].CurrentMember.children,[Measures].[Remaining]), iif( [Line].CurrentMember is [Line].[Todas Linea].[Comercial], Sum([Line].CurrentMember.children,[Measures].[Remaining]), iif( [Line].CurrentMember.Level is [Line].[Line], iif( [Measures].[System Stock] < [Measures].[Real Stock ], null, [Measures].[System Stock] - [Measures].[Real Stock] ), [Measures].[System Stock] - [Measures].[Real Stock] ) ) ), Sum(crossjoin(descendants([Enterprise].CurrentMember,, leaf ), |
|
Hello, I have one MDX that uses 4 nested SUM. It´s very slow and need to have an advice for implement a better version of this: The Dimensions: TIME: ALL-YEAR-QUARTER-MONTH-DAY ENTERPRISE ALL-ENTERPRISE-STORE LINE ALL-COMERCIAL-LINE-SUBLINE-ARTICLE The CORE: At Line level, Day Level and Store Level must calc: iif( [Measures].[System Stock] < [Measures].[Real Stock ], null, [Measures].[System Stock] - [Measures].[Real Stock] ), If is lower than LINE level [Measures].[System Stock] - [Measures].[Real Stock] If its higher than LINE level: SUM So I implement this MDX called [Measures].[Remaining] ---------------------------------------------------------------------------- iif( isleaf([Date].CurrentMember), iif( isleaf([Enterprise].CurrentMember), iif( [Line].CurrentMember is [Line].[All Line], Sum([Line].CurrentMember.children,[Measures].[Remaining]), iif( [Line].CurrentMember is [Line].[Todas Linea].[Comercial], Sum([Line].CurrentMember.children,[Measures].[Remaining]), iif( [Line].CurrentMember.Level is [Line].[Line], iif( [Measures].[System Stock] < [Measures].[Real Stock ], null, [Measures].[System Stock] - [Measures].[Real Stock] ), [Measures].[System Stock] - [Measures].[Real Stock] ) ) ), Sum([Enterprise].CurrentMember.children) ), Sum([Time].CurrentMember.children) ) It´s VERY SLOW, but works. So please, need some advice of implement a better version of this. Thanks -- Message posted via http://www.sqlmonster.com |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
EXCELLENT! If I had a Hat, surely I would take off !!! I had the same result with a delay of normal cubes. Neither 30 seconds(my second try), or the worst 30 minutes (first try) NonemptyCrossJoin is very useful as combinates filter, crossjoin and NonEmpty. About the MDX you send, I have a little questions: Remaining MDX ----------------------- Sum( NonEmptyCrossjoin( descendants([Enterprise].CurrentMember,,leaves), descendants([Time].CurrentMember,,leaves), {[Measures].[Real Stock]},2 ), [Measures].[Remaining1] ) in descendants([Time].CurrentMember,,leaves), when I use double Comma ,, I mean that is all Descendants? Only the leaf level of descendants? in {[Measures].[Real Stock]},2 Why only Real stock, and not [System Stock] Only one meassure is needed? And this number 2 means that they´re descendantsTime and descendatEnterprise? Thanks you Jéjé! You are very good. -- Message posted via SQLMonster.com http://www.sqlmonster.com/Uwe/Forums...-olap/200509/1 |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Well, this MDX is quite heavy. Now with this modifies is lite. The target of my cube was to Calculate the Remaining in an Inventory process. An inventory Process needs to calc the remaining (at Line level) of products (articles) As the hierarchy is All - Commercial - Line - Subline - Article, if in a store the SystemStock says must be 30 Adidas shoes, and I found 35, I have then +5 in remaining The same case of 20 Nike in SystemStock, and found 10 in RealStock (inventory) I have -10 in reamining At Line level (Shoes) I CAN SUM, so Adidas (+5) + Nike (-10) = Shoes -5 If the difference is positive at line level, I don´t need it: So T-Shirt (+4) transforms in T-Shirt (0) When I see at Commercial Level, all Remainings for all lines must SUM Shoes(-5) + coat(-4) = (-9) remaining Why this? Because if I have (-10) coats, and have (+25) socks, then without this opperation I´ll have that I have (+15) articles in this store. And the Management for the Boss of a Store could show wrong information. The other thing that I observed, was that as the formula is SystemStock (SS) - RealStock (RS), when I consult at Enterprise level, it MIX all SS-RS values in stores, so if I have SS RS Remainig (Store1) 100 80 20 SS RS Remainig (Store2) 60 75 0 SS RS Remainig Enterprise (all stores) 160 155 5 And need the 20 + 0 = 20 remaining articles. The same case for Day lavel, that Mix all days. I have a final Calculation, that not posted name INDICATOR (IIC) that calcs: Remaining / SystemStock When you see data in Excel, you can select to show only one month (July for example) and you see a sumarized column like AllYear (2005) and Allyears (2004+2005) I have then: ------------------July------- 2005 SystemStk 25894 25894 RealStock 25548 25548 Remaining 415 2385 <----Nottice this? IIC(Indicator) 1.60% 9.21% This is because the MDX of remaining always calcs for 2005, all remaining for all childs (From January to September, including July) This is a feature thata I never solved, in all my cubes. I don´t know if I must Alter SystemStk to show for 2005 the ressult of the Sum of all months, or Try to recalculate the remaining MDX to show only this 415 value. Don´t know if you had the same problem using MsExcel of course. Well, this is a not little explanation of what I did in my cube. I don´t know too much about preaggregated Cubes. For that 3 things, I suppose * I use Analysis Services Standard Version * I have in Fact table 2 columns: Possitive and Negattive, that stores SS-RS and RS-SS, when 0 then 0 in both cases, maybe can help this * I have SQL and Business Intelligence 2005 June CTP, studio. So Maybe I can work with precalculated there. Thanks a lot Jéjé for your time. And thanks for contributing me for my growing in Business Intelligence. -- Message posted via http://www.sqlmonster.com |
#7
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |