English 中文(简体)
Semi-additive measures problem - sum snapshots for each month, but not across months
原标题:
  • 时间:2009-11-26 04:01:01
  •  标签:
  • ssas
  • mdx

Proficient with SQL but new to MDX, I am having trouble getting my head around this:

I have a fact table that contains snapshots of account balances monthly. I need to roll up the balances as a semi-additive measure - straight sum doesn t work, obviously, for balances. However, I DO need to sum all the balances within EACH month, separately, by adding together the balances for all accounts, and so the "lastnonempty" notion isn t working for me either. Example, if the facts look like this:

Date        AccountNo     Balance
2009-01-31  1111          $100
2009-01-31  2222          $100
2009-01-31  4444          $100
2009-01-31  5555          $100

2009-02-28  1111          $100
2009-02-28  2222          $200
2009-02-28  3333          $500
2009-02-28  5555          $50

etc.

And I have an account dimension that groups accounts into a major category / minor category / account hierarchy, I need output like this that sums the balances for each month across all accounts:

Month        Total
January 09   $400
February 09  $850

And by broken out by account type:

Month        Total
January 09   $400
  Type 1      $200
    1111       $100
    2222       $100
  Type 2     $200
February 09  $850
  Type 1     $300
  Type 2     $550

BUT, the balances should NOT sum across months, quarters or years, because it makes no sense, and they d be counted twice. Any longer time interval should show the close of period:

Quarter    WRONG    Correct
Q1         $1250    $850   // should be the sum of balances for the *last* month in Q1
  Type 1   $500     $300
  Type 2   $759     $550

If I use the stock "lastnonempty" aggregation, I seem to get only the one, literal last account row for a month, not the sum of the account balances for the last month. It s as if the total for the month is showing just the balance taken from one random account present in that month, and not the total. (I m sure it s not really random, probably is picking one based on storage order or something)

I m sure I am just doing something simple, wrong...

最佳回答

I think I solved this one: my source data having the balances was very sparse - there was a row only for non-zero balances, and NO rows for accounts when the balance is zero. That made everything screwy (imagine as inventory, where you have counts of parts, and those counts are often zero, but when they are 0 then the row is just missing from the fact table)

I was able to create a view at the data source that would "add back in" all the additional rows, with zero balances, and after that the ClosingPeriod() function started working as expected.

问题回答

暂无回答




相关问题
In SSAS, can parent-child DATAMEMBER name be customised

In a parent-child dimension in SSAS, the datamember is automatically named the same as the parent. E.g. Division X Risk Register Division X Risk Register Department A Risk Register Department B ...

Adding a Total column to MDX

I have the following query that gives me an extract (I am putting this into a CSV from my cube). I want to show the Total of all NRx in a column as the first column NRx and the rest of the NRx ...

using colors in calculated member

Im using this query in MDX for a calculate measure topcount(nonempty([StatusPlanes].[Status].Status.members,[Measures].[Planes]),1)(0).member_caption this will bring me this result Dimension1 ...

Using colors with MDX calculated measure

I m using this query in MDX for a calculated measure topcount(nonempty([StatusPlanes].[Status].Status.members,[Measures].[Planes]),1)(0).member_caption This will bring me this result Dimension1 ...

Calculated Member for Cumulative Sum

First some background: I have the typical Date dimension (similar to the one in the Adventure Works cube) and an Account dimension. In my fact table I have daily transaction amounts for the accounts. ...

What is MDX and what is its use in SAP BPC

I would like to know more about "MDX" (Multidimensional Expressions). What is it? What is it used for? Why would you use it? Is it better than SQL? What is its use in SAP BPS (I haven t seen BPC, ...

热门标签