Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

Need a way to SCOPE to control custom rollups for certain calculated measures

$
0
0

Having some issues with scope statements.

Take the AdventureWorks Cube with [Sales Amount] and [Order Quantity]. Let’s say we want to create a calculated measure, [Amount Per Order] which is simply [Sales Amount] / [Order Quantity]. You’d see something like this:

Row Labels

Sales Amount

Order Quantity

Amount Per Order

AdventureWorks Cycle

$223,224,408.40

1,592,253

$140.19

European Operations

$109,809,274.20

794,776

$138.16

North   America Operations

$112,179,900.00

789,021

$142.18

Canadian Division

$109,809,274.20

774,776

$141.73

USA Operations

$2,370,625.80

14,245

$166.42

Central Division

$109,874.20

770

$142.69

Northeast Division

$809,222.60

5,231

$154.70

Northwest Division

$210,980.20

1,412

$149.42

Southeast Division

$809,274.20

4,413

$183.38

Southwest Division

$431,274.60

2,419

$178.29

Pacific   Operations

$1,235,234.20

8,456

$146.08

Now let’s say we have a business requirement which says we need to ignore the Order Quantity for the Central Division. So we apply a scope statement to set the Order Quantity for the for the Central Division to 0. However, because [Amount Per Order] is a function of [Order Quantity] and [Sales Amount] we have a problem. 

So the desired solution then is to simply display the [Amount Per Order] for the Central Division as 0, but for all of the Rollups – [USA Operations], [North America Operations] and [AdventureWorks Cycle]. So we similarly have a scope statement for [Amount Per Order] to set the value to 0 for [Central Division]. This is what we would like to see.

Row Labels

Sales Amount

Order Quantity

Amount Per Order

AdventureWorks Cycle

$223,114,534.20

1,591,483

$140.19

European   Operations

$109,809,274.20

794,776

$138.16

North   America Operations

$112,070,025.80

788,251

$142.18

Canadian Division

$109,809,274.20

774,776

$141.73

USA Operations

$2,260,751.60

13,475

$167.77

Central Division

$109,874.20

0

$0.00

Northeast Division

$809,222.60

5,231

$154.70

Northwest Division

$210,980.20

1,412

$149.42

Southeast Division

$809,274.20

4,413

$183.38

Southwest Division

$431,274.60

2,419

$178.29

Pacific   Operations

$1,235,234.20

8,456

$146.08

However this is not what we’re getting in our Cube.  What we’re actually seeing is that the Rollup aggregations seem to ignore the scope statements so we’re still getting the invalid [Order Quantity] amounts for [Central Division] propagated to all of our Rollups.  This is throwing off our Rollup calculations for [Amount Per Order]. It’s as if the Rollup aggregations are being calculated before our scope statements. 


Chad Dotzenrod SWC | TECHNOLOGY PARTNERS 1420 Kensington Road, Suite 110 Oak Brook, Illinois 60523-2144 http://www.swc.com


Viewing all articles
Browse latest Browse all 14337

Trending Articles