SQLServerCentral » SQL Server 2008 » SQL Server 2008 - General » How do I calculate totals for a distributed measure in SSAS?InstantForum 2016-2 FinalSQLServerCentralhttps://www.sqlservercentral.com/Forums/SQLServerCentralFri, 21 Jul 2017 06:51:23 GMT20How do I calculate totals for a distributed measure in SSAS?https://www.sqlservercentral.com/Forums/FindPost1444244.aspxI'm not sure if this is the right place to post my question but here goes.
I have an OLAP cube consisting of quite a few tables.
In this scenario there's only reason to look at one fact table with costs.
This table constructed by a join in SQL with a table of distribution keys.
The purpose is to split costs across Company, Cost Center, etc.
The joining keys are Company, CostCenter, AccountGroup, DateFrom, and DateTo.
As such, the number of rows can be blown up a multitude of times.
If we look at a simple case with just one variable:
Cost Distribution Distributed Cost Count DistrCalc
Company A 100 0.8 80 1 0.8
Company B 200 0.2 40 1 0.2
Total 300 1.0 120 2 0.5
I need to show the Distribution figure in the cube.
I do that by dividing Distribution with Count as you can see in the final column in the table above, DistrCalc.
Here's the cube formula
Iif( [Measures].[Count] = 0 Or [Measures].[] is NULL
, NULL
, [Measures].[Distribution] / [Measures].[Count])
The Total of 0.5 for DistrCalc is clearly wrong. I should be 1.0 (or if not possible, NULL).
Since we use Excel as the frontend tool we could easily switch off totals but totals are relevant for other measures.
So how do I get around this problem?
I'm thinking that some sort of Scope statement could it. But it has to span across all the variables from the SQL join.
My level of expertise in MDX is unfortunately not very high, and Google hasn't provided me with a usable result.
Thank you in advance!
Hans RiisFri, 19 Apr 2013 01:07:21 GMTHans Riis