Quantcast
Channel: SQLServerCentral » Data Warehousing » Analysis Services » Latest topics
Viewing all articles
Browse latest Browse all 1341

Calculating Maximum Amount from a Running Total per Account

$
0
0
Hi,I hope somebody can help. I need to calculate a maximum amount based upon a daily running total (per account) within MDX/SSAS and have this displayed in the cube.I have created an example running total for daily sales amounts. WITH MEMBER [Measures].[RunningTotal] AS aggregate( PeriodsToDate([Calendar].[Date Hierarchy].[All].level,[Calendar].[Date Hierarchy].currentmember ),[Measures].[Amt])SELECT {[Measures].[Amt], [Measures].[RunningTotal]} ON 0, [Account].[AccountId].members * [Calendar].[Date Hierarchy].[Date].members on 1FROM [MyCube];EG data output:AccID Date Amt RunningTotalAcc1 2012-01-01 0 0Acc1 2012-01-02 2 2Acc1 2012-01-03 3 5Acc1 2012-01-04 -1 4Acc1 2012-01-05 4 [b]8 [/b]--This being the MAX running total value.Acc1 2012-01-06 -5 3Acc1 2012-01-07 0 3Acc1 2012-01-08 0 3Acc1 2012-01-09 1 4In essence, the Amt equates to a transaction amount. The generated running total is a balance (e.g. Standalone versus cumulative values)....Aim is to provide a CalcMeasure which will have Acc1 = 8.I've unsuccessfully tried to capture the MAX SalesAmt by Date using RANK() and HEAD() functions. My attempts appear to change the nature of the running total.Also not sure how best to approach only applying the running total to [Account].[AccountId]. Would this be best acheived via SCOPE statement?

Viewing all articles
Browse latest Browse all 1341

Trending Articles