Vous êtes sur la page 1sur 42

BW OLAP Aggregation

Lothar Schubert, BW RIG SAP Labs America, LLC March 2003

Introduction The Role of the OLAP Engine

Basic InfoCube

Business Explorer

With Data

InfoProvider Interface

Master Data MultiProvider ODS Object

OLAP Engine

No Data

Virtual InfoCube

InfoSet
SAP AG 2002, Title of Presentation, Speaker Name

Overview
KF/CKF Properties and Exception Aggregation OLAP Processor Under the Hood Case Study Revenue Calculation Calculation with Reference to Characteristic Formula Collision Percentage and Summary Functions

SAP AG 2002, Title of Presentation, Speaker Name

Overview
KF/CKF Properties and Exception Aggregation OLAP Processor Under the Hood Case Study Revenue Calculation Calculation with Reference to Characteristic Formula Collision Percentage and Summary Functions

SAP AG 2002, Title of Presentation, Speaker Name

Exception Aggregation Settings on KF Level

Example:
Department Headcount D1 100 D2 80 Result 180 << SUM Month Headcount 1/3/03 160 2/3/03 180 Result 170 << AVG, with regards to Month

SAP AG 2002, Title of Presentation, Speaker Name

Exception Aggregation - Counting


CNT: Counting of all values with respect to reference characteristic Business Scenario: How many different materials does a customer have "Open Orders" for?

SAP AG 2002, Title of Presentation, Speaker Name

Exception Aggregation - Average


AVG: Average of all values with respect to reference characteristic Business Scenario: Average "Open Order Qty" per Material Calculation Steps
Aggregate values using standard aggregation

Aggregate values using exception aggregation

Drill-down by Material explains result


309 = ( 225 + 20 + 630 + 360) / 4

SAP AG 2002, Title of Presentation, Speaker Name

Exception Aggregation First & Last Value


FIR, LAS Exception Aggregation (see note 310791)
Should only be used with non-cumulative key figures Generally use time characteristic as reference characteristic If being used for cumulative key figures: Completeness of values with respect to reference characteristic necessary. If being used with non time char. as reference characteristic: Sorting is done ascending according to key (internal presentation)

Plant

Posting Date Value 1 06/15/03 25 1 06/16/03 15 2 06/15/03 20 Posting Date Value 1 2

Cumulative InfoCube Example:

Plant

Result

15 << last posted value concerning plant 1 - 6/16 20 << last posted value concerning plant 2 - 6/15 15 << last posted value concerning plant 1+2 - 6/16

SAP AG 2002, Title of Presentation, Speaker Name

Key Figure (Selection, Formula) Properties

Note, that the those calculations always act on displayed data only
SAP AG 2002, Title of Presentation, Speaker Name

CKF Aggregation Behavior Assignment


Complexity Assignment, if of type= KF Exception Aggregation Behavior (and reference) can be set freely Default is setting of underlying Basic KF PROPERTIES

SAP AG 2002, Title of Presentation, Speaker Name

10

CKF Aggregation Behavior Simple


Complexity Simple, if exclusively operands of same aggregation, where operands can have complexity Simple themselves (KF, Constants, CKF) Before / After Aggregation can be set

SAP AG 2002, Title of Presentation, Speaker Name

11

CKF Aggregation Behavior Complex


Complexity Complex applies to all other cases Enhance options are not ready for input (greyed out) Calculation always occurs after aggregation

SAP AG 2002, Title of Presentation, Speaker Name

12

Overview
KF/CKF Properties and Exception Aggregation OLAP Processor Under the Hood Case Study Revenue Calculation Calculation with Reference to Characteristic Formula Collision Percentage and Summary Functions

SAP AG 2002, Title of Presentation, Speaker Name

13

OLAP Initialization
Check Authorizations
Is it ok to execute query? Is it ok to read data from InfoProvider?

Process Variables
Exit for global variables (before variable input) is processed Prompt for variable input Exit for global variables (that failed before input) is processed Variable values are distributed to fixed filter, hierarchy settings, dynamic filter, conditions & exceptions, formulas,

Initialize OLAP Processor Notify Presentation hierarchies (if used) Check time stamps for OLAP cache (and release respective Ids)

SAP AG 2002, Title of Presentation, Speaker Name

14

OLAP Processor in Detail I

1. OLAP request arrives from client


Request for free characteristics Request for Dynamic filters

2. Include additional characteristics necessary for aggregation / calculation. For example:


Exception aggregation Elimination of internal business volume Formula variables with replacement from attribute value, if used in restricted key figure (RKF)

3. Check authorization for navigation state (where necessary) 4. Search for Cached data in OLAP Cache
Skip steps 5-14 and go to step 15 if cached data is found

SAP AG 2002, Title of Presentation, Speaker Name

15

OLAP Processor in Detail II

if OLAP Cache is NOT utilized

5. Request data from database 6. Receive data from database


Data arrives in blocks up to 1000 rows Data is still separated by InfoProvider (in case of MultiProvider) Data is still separated by Aggregate of InfoCube Data is still separated into cumulative and non-cumulative key figures

7. Call BusinessAdd-In Virtual Characteristics and Key Figures 8. Check global filters (if not already done by database) 9. Add attributes values for variables with replacement from attribute used in RKF 10. Separate data according to RKFs and selections in structure elements 11. Perform currency translation 12. Process sums and calculated key figures (CKFs) before aggregation 13. Aggregate data to detail level (see 2.) 14. Perform Hierarchy aggregation

SAP AG 2002, Title of Presentation, Speaker Name

16

OLAP Processor in Detail III


15. Filter and aggregate data (result lines) 16. Perform Elimination of Internal Business Volume (where applicable) 17. Perform Exception aggregation

18. Execute Currency/Unit aggregation 19. Add attributes values for variables with replacement from attribute used in formulas 20. Calculate formulas and CKFs after aggregation
Check Currencies/Units

21. Perform List Operations, e.g.


Sort Conditions Local calculations/aggregations Cumulated values

SAP AG 2002, Title of Presentation, Speaker Name

17

Overview
KF/CKF Properties and Exception Aggregation OLAP Processor Under the Hood Case Study Revenue Calculation Calculation with Reference to Characteristic Formula Collision Percentage and Summary Functions

SAP AG 2002, Title of Presentation, Speaker Name

18

OLAP Engine, w/ Example of Revenue Calculation


InfoCube contains field Quantity Material Attribute contains field Price Revenue should be calculated by the OLAP Processor

KH_ATTRIBUTE_REPLACEMENT
Calendar year Key Figures KHMAT2 KHMAT2 M1 M2 Overall Result Quantity, CKF (QU * PR)

Quantity 11.000 PC 15.000 PC 26.000 PC

CKF (QU * PR) $ 110.00000 PC $ 300.00000 PC $ 410.00000 PC

KH_ATTRIBUTE_REPLACEMENT
Calendar year Key Figures KHMAT2 Calendar year 2001 2002 Overall Result Quantity, CKF (QU * PR)

Quantity 12.000 PC 14.000 PC 26.000 PC

CKF (QU * PR) $ 190.00000 PC $ 220.00000 PC $ 410.00000 PC

SAP AG 2002, Title of Presentation, Speaker Name

19

Data Model (1)

Key Figure Quantity

InfoCube Definition

SAP AG 2002, Title of Presentation, Speaker Name

20

Data Model (2)

Price Attributes

InfoCube Definition

SAP AG 2002, Title of Presentation, Speaker Name

21

Data

InfoCube

Material Master

SAP AG 2002, Title of Presentation, Speaker Name

22

Formula Variable, based on Attribute Value

SAP AG 2002, Title of Presentation, Speaker Name

23

1. Try: Usage in Formula

KHMAT2 M1 M2 Overall Result

Quantity 11.000 PC 15.000 PC 26.000 PC

'KHF1' * 'Quantity' $ 110.00000 PC $ 300.00000 PC X

Calendar year 2001 2002 Overall Result

Quantity 12.000 PC 14.000 PC 26.000 PC

'KHF1' * 'Quantity' X X X

SAP AG 2002, Title of Presentation, Speaker Name

24

2. Try: RKF, Before Aggregation (1)

Price

SAP AG 2002, Title of Presentation, Speaker Name

25

2. Try: RKF, Before Aggregation (2)

Quantity = AVG, CKF, Before Material M1 M1 M2 M2 Material M1 M2 Result Year 2001 2001 2002 2002 Year Quantity 5 6 7 Price 10 10 20

Quantity Price 11 15 26

20 40 60

KHMAT2 M1 M2 Overall Result

Quantity 11.000 PC 15.000 PC 26.000 PC

KHK1_BEFORE $ 20.00 $ 40.00 $ 60.00

Calendar year 2001 2002 Overall Result

Quantity 12.000 PC 14.000 PC 26.000 PC

KHK1_BEFORE $ 30.00 $ 30.00 $ 60.00

SAP AG 2002, Title of Presentation, Speaker Name

26

3. Try: RKF, After Aggregation

Quantity = SUM, CKF, After Material M1 M2 Material M1 M2 Result Year 2001 2001 Year Quantity Price 11 15 Quantity Price 11 15 26

KHMAT2 M1 M2 Overall Result

Quantity 11.000 PC 15.000 PC 26.000 PC

KHK1_AFTER $ 10.00 $ 20.00 $ 30.00

10 20 30

Calendar year 2001 2002 Overall Result

Quantity 12.000 PC 14.000 PC 26.000 PC

KHK1_AFTER $ 30.00 $ 30.00 $ 30.00

SAP AG 2002, Title of Presentation, Speaker Name

27

4. Try: Formula, using CKF from before

Quantity = SUM, CKF, After Material M1 M1 M2 M2 Material M1 M2 Result Material M1 M2 Result Year 2001 2002 2001 2002 Year Quantity 5 6 7 8

Qu * Pr = Formula Price Qu * Pr

Quantity Price 11 15 26 Quantity Price 11 15 26

Qu * Pr 10 20 30 Qu * Pr 110 300 780

Year

KHMAT2 Quantity M1 11.000 PC M2 15.000 PC Overall Result 26.000 PC


Calendar year Quantity 2001 12.000 PC 2002 14.000 PC Overall Result 26.000 PC

KHK1_AFTER $ 10.00 $ 20.00 $ 30.00


KHK1_AFTER $ 30.00 $ 30.00 $ 30.00

'Quantity' * 'KHK1_AFTER' $ 110.00000 PC $ 300.00000 PC $ 780.00000 PC


'Quantity' * 'KHK1_AFTER' $ 360.00000 PC $ 420.00000 PC $ 780.00000 PC

10 20 30

Quantity = SUM, CKF, After Material M1 M1 M2 M2 Material Year 2001 2002 2001 2002 Year 2001 2002 Result Quantity 5 6 7 8

Qu * Pr = Formula Price Qu * Pr

Quantity Price 12 14 26

30 30 30

Qu * Pr 360 420 780

SAP AG 2002, Title of Presentation, Speaker Name

28

5. Try: Revenue Calculation within RKF (1)

SAP AG 2002, Title of Presentation, Speaker Name

29

5. Try: Revenue Calculation within RKF (2)

Quantity = SUM, CKF, After Material M1 M1 M2 M2 Material M1 M2 Result Year 2001 2002 2001 2002 Year Quantity 5 6 7 8

Qu * Pr = CKF Price Qu * Pr

KHMAT2 Quantity M1 11.000 PC M2 15.000 PC Overall Result 26.000 PC


Calendar year Quantity 2001 12.000 PC 2002 14.000 PC Overall Result 26.000 PC
SAP AG 2002, Title of Presentation, Speaker Name

CKF (QU * PR) $ 110.00000 PC $ 300.00000 PC $ 410.00000 PC


CKF (QU * PR) $ 190.00000 PC $ 220.00000 PC $ 410.00000 PC

Quantity Price 11 15 26

10 20 30

Qu * Pr 110 300 410

30

Some additional Notes


Be careful when using multiple aggregation types (see example below, for a mix of before and after). Allowed in CKF:

= KF * Attribute, = KF / Attribute, = Attribute, = Attribute / KF

e.g. = Quantity * Price e.g. = Quantity / Price e.g. = Price e.g. = Price / Quantity

Not allowed in CKF (i.e. leading potentially to unwanted results):


Performance impacts, in case of before aggregation

All required records have to be read into OLAP processor (and processed individually) No aggregates cannot be applied Datasets are processed individually per InfoProvider first Before aggregation does not allow formulas with mix of KF types

In case of MultiProviders

In case of Inventory (non cumulative) InfoCubes

Always consider calculation already in UpdateRules (see Note 379832)


KHMAT2 M1 M2 Overall Result
Calendar year 2001 2002 Overall Result

Quantity 11.000 PC 15.000 PC 26.000 PC


Quantity 12.000 PC 14.000 PC 26.000 PC

KHK1_BEFORE $ 20.00 $ 40.00 $ 60.00


KHK1_BEFORE $ 30.00 $ 30.00 $ 60.00

KHK1_AFTER $ 20.00 $ 40.00 $ 60.00


KHK1_AFTER $ 30.00 $ 30.00 $ 60.00

CKF (QU * PR) $ 110.00000 PC $ 300.00000 PC $ 410.00000 PC


CKF (QU * PR) $ 190.00000 PC $ 220.00000 PC $ 410.00000 PC

SAP AG 2002, Title of Presentation, Speaker Name

31

Overview
KF/CKF Properties and Exception Aggregation OLAP Processor Under the Hood Case Study Revenue Calculation Calculation with Reference to Characteristic Formula Collision Percentage and Summary Functions

SAP AG 2002, Title of Presentation, Speaker Name

32

Motivation
Mostly, the OLAP first aggregates data and then applies calculations Sometimes you would like to change this sequence (however you do not want to use before aggregation for all characteristics combinations, due to performance reasons) Example Cube Data:
Price per Unit

Here, it would be ok to aggregate first by Material and Month, but its required to perform the calculation prior to aggregation on Order.

SAP AG 2002, Title of Presentation, Speaker Name

33

After Aggregation would deliver wrong results

SAP AG 2002, Title of Presentation, Speaker Name

34

Usage of Reference to Characteristic (1)

SAP AG 2002, Title of Presentation, Speaker Name

35

Usage of Reference to Characteristic (3)

This attribute is available for every Characteristic (also 2.0b/2.1c) Also here: Consider performance impacts Perhaps calculation can already occur in Update Rules.

SAP AG 2002, Title of Presentation, Speaker Name

36

Overview
KF/CKF Properties and Exception Aggregation OLAP Processor Under the Hood Case Study Revenue Calculation Calculation with Reference to Characteristic Formula Collision Percentage and Summary Functions

SAP AG 2002, Title of Presentation, Speaker Name

37

Formula Collision
Quantity 2001 12.000 PC 2002 +14.000 PC Summary 26 PC Quantity 2001 12.000 PC 2002 14.000 PC Summary 26 PC Quantity 2001 12.000 PC 2002 14.000 PC Summary 26 PC Quantity 12.000 PC 14.000 PC 26 PC Quantity 12.000 PC 14.000 PC 26 PC Quantity 12.000 PC 14.000 PC 26 PC

*'Quantity' * 'Quantity'
144.00000 PC^2 196.00000 PC^2 676.00000 PC^2 'Quantity' * 'Quantity' 144.00000 PC^2 196.00000 PC^2 676.00000 PC^2 'Quantity' * 'Quantity' 144.00000 PC^2 196.00000 PC^2 340.00000 PC^2

Available in case of formulas with multiple structures, under Formula Properties. Collisions always occur when point and dash calculations or functions are mixed in competing formulas. If you do not make a definition, the formula that was set (defined and saved) last takes priority.
38

SAP AG 2002, Title of Presentation, Speaker Name

Overview
KF/CKF Properties and Exception Aggregation OLAP Processor Under the Hood Case Study Revenue Calculation Calculation with Reference to Characteristic Formula Collision Percentage and Summary Functions

SAP AG 2002, Title of Presentation, Speaker Name

39

Percentage Functions (1)


a%b a%Ab difference in percentage: share in percentage:

How much does a value deviate from the absolute amount of b: = (a-)/abs(b)? How large is a share a for the total value b: = a/abs(b)

%CTa
GTa

share in terms of percentage for the result:


share in terms of percentage for the total result:

The value of the key figure a is related to the next higher value that is aggregated (the "subresult" of a with respect to a characteristic is 100%). The value of the key figure a is related to the aggregated value for all characteristics (the "result" of the entire table for the key figure a is 100%).

%RTa

share in terms of percentage for the report result:

The value of the key figure a is related to the aggregated value for all characteristics, for which the dynamic filter is ignored. If, for example, a free characteristic is restricted by a filter value, the global result of the key figure a in the displayed table is not 100%. The aggregation via all filter values results in 100%.

SAP AG 2002, Title of Presentation, Speaker Name

40

Percentage Functions (2)


KHMAT2 KHMAT2 M1 Calendar year Quantity 2001 5.000 PC 2002 6.000 PC Result 11.000 PC 2001 7.000 PC 2002 8.000 PC Result 15.000 PC 26.000 PC 'Quantity' % 10 -50.00000 % -40.00000 % 10.00000 % -30.00000 % -20.00000 % 50.00000 % 160.00000 % 'Quantity' %A 10 50.00000 % 60.00000 % 110.00000 % 70.00000 % 80.00000 % 150.00000 % 260.00000 % %CT 'Quantity' 45.45455 % 54.54545 % 42.30769 % 46.66667 % 53.33333 % 57.69231 % 100.00000 % %GT 'Quantity' 19.23077 % 23.07692 % 42.30769 % 26.92308 % 30.76923 % 57.69231 % 100.00000 % %RT 'Quantity' 19.23077 % 23.07692 % 42.30769 % 26.92308 % 30.76923 % 57.69231 % 100.00000 %

M2

Overall Result

KHMAT2

M1 'Quantity' % 10 -50.00000 % -40.00000 % 10.00000 % 'Quantity' %A 10 50.00000 % 60.00000 % 110.00000 % %CT 'Quantity' 45.45455 % 54.54545 % 100.00000 % %GT 'Quantity' 45.45455 % 54.54545 % 100.00000 % %RT 'Quantity' 19.23077 % 23.07692 % 42.30769 %

Calendar year Quantity 2001 5.000 PC 2002 6.000 PC Overall Result 11.000 PC

a%b

difference in percentage

a%Ab %CTa GTa %RTa

share in percentage share in terms of percentage for the result share in terms of percentage for the total result share in terms of percentage for the report result

SAP AG 2002, Title of Presentation, Speaker Name

41

Summary Functions
SUMGTa
The value of the key figure a is related to the aggregate value via all characteristics. Aggregation is completed using the deepest-level characteristic.

SUMCTa
The value of the key figure a is related to the next highest aggregate value.

SUMRTa
The value of the key figure a is related to the aggregate value of all characteristics in which the dynamic filter is ignored.
KHMAT2 KHMAT2 M1 Calendar year Quantity 2001 5.000 PC 2002 6.000 PC Result 11.000 PC 2001 7.000 PC 2002 8.000 PC Result 15.000 PC 26.000 PC SUMCT 'Quantity' 11.000 PC 11.000 PC 26.000 PC 15.000 PC 15.000 PC 26.000 PC 26.000 PC SUMGT 'Quantity' 26.000 PC 26.000 PC 26.000 PC 26.000 PC 26.000 PC 26.000 PC 26.000 PC SUMRT 'Quantity' 26.000 PC 26.000 PC 26.000 PC 26.000 PC 26.000 PC 26.000 PC 26.000 PC

M2

Overall Result

KHMAT2

M1 SUMCT 'Quantity' 11.000 PC 11.000 PC 11.000 PC SUMGT 'Quantity' 11.000 PC 11.000 PC 11.000 PC SUMRT 'Quantity' 26.000 PC 26.000 PC 26.000 PC

Calendar year Quantity 2001 5.000 PC 2002 6.000 PC Overall Result 11.000 PC

SAP AG 2002, Title of Presentation, Speaker Name

42

Vous aimerez peut-être aussi