CXO-Cockpit Hands-On MDX Workshop · Are defined in CXO-Cockpit by ... A Cube Calculation must...

45
CXO-Cockpit Hands-On MDX Workshop Marcel Legerstee Jeroen de Soeten

Transcript of CXO-Cockpit Hands-On MDX Workshop · Are defined in CXO-Cockpit by ... A Cube Calculation must...

CXO-Cockpit Hands-On MDX Workshop

Marcel LegersteeJeroen de Soeten

Agendao MDX Query basics: structure & conceptso CXO-Cockpit Cube Calculations

o Basic calculationso Using MDX functions

o CXO-Cockpit MDX lists o Basic MDX listso Using set and tuple set expressions

o MDX troubleshootingo Hands-on exercises with examples of powerful cube calcs and MDX lists

- 12:30 – 14:30 Training- 14:30 – 15:00 Break- 15:00 – 16:30 Training

MDXo MDX = MultiDimensional eXpressionso It is a query language for OLAP databaseso It is also a calculation language (syntax similar to spreadsheet formulas)o MDX has been embraced by wide variety of OLAP vendors

Basic MDX QueryRows, Columns & Where Statement

SELECT { SET 1 } ON COLUMNS,

{ SET 2 } ON ROWS

FROM CUBE

WHERE( TUPLE )

COLUMNSAre defined in CXO-Cockpit byyour columns list

ROWSAre defined in CXO-Cockpit by your rows list

CUBEIs defined in CXO-Cockpit by thesource system in system settins

WHEREContains all other dimensionsthat are not specified in therows or columnsThe WHERE is constructed bythe POV or fixed dimensions

Basic MDX Concepts

o A Member is one specific Member from 1 specific Dimension and is typically unique. The MDX Syntax for a Member is:

[DIMENSION].[HIERARCHY].[MEMBER]

o A Set is a group of Members from 1 specific Dimension and is typically unique. The MDX Syntax for a Set is:

{ [ACC].[ACC].[SALES], [ACC].[ACC].[COGS] }

o A Tuple is a group of Members from different Dimensions. The MDX Syntax for a Tuple is:

( [PER].[PER].[JANUARY], [CAT].[CAT].[ACTUAL] )

o A Tuple Set is a group of Tuples with the same dimensional setup. The MDX Syntax for a Tuple Set is:

{ ( [PER].[PER].[JANUARY], [CAT].[CAT].[ACTUAL] ),( [PER].[PER].[FEBRUARY], [CAT].[CAT].[FORECAST] ) }

Member, Set, Tuple & Tuple Set

Basic MDX QueryExample

SELECT { ( [PER].[PER].[JANUARY], [CAT].[CAT].[ACTUAL] ),{ ( [PER].[PER].[FEBRUARY], [CAT].[CAT].[FORECAST] ) } ON COLUMNS,{ [ACC].[ACC].[SALES], [ACC].[ACC].[COGS] }ON ROWSFROM CUBEWHERE( [YER].[YER].[2016], [ENT].[ENT].[HQ] )

ROWSSet combining multiple accounts (same dimension)

COLUMNSTuple Set combining two tuplesboth having PER and CAT as dimensions

WHERETuple with the other dimensions

CXO-Cockpit Cube Calculation

o A Cube Calculation always calculates a new Membero Cube Calculations can be applied to Columns (1), Rows (2) or the Where Statement (3)

Structure & Context - Basic calculations

1

2

3

CXO-Cockpit Cube Calculations (1)

A Cube Calculation must always return one of the following results:o A number

o A fixed number like “100”o A calculation of other members retuning a number like “[Costs] / [Sales] * 100”o A MDX function returning a number like “AVG({[Product1], [Product2]})”

o A Member of the same Dimensiono A reference to another member e.g. YTD: “[VIW].[VIW].[YTD_Input]”o A MDX function returning a member from the same Dimension like “[YER].[YER].[2016].Prevmember”

o A Tuple containing at least a Member from the same Dimensiono For example cube calculation of dimension [CAT] called latest budget:

“([CAT].[CAT].[Budget], [VER].[VER].CurrentMember.LastSibling)”

Structure & Context - Basic calculations

CXO-Cockpit Cube Calculations (2)

o The cube calculation must have a unique nameo It must be linked to a dimension (-hierarchy)o In the Calculated member you can use explicit members from other dimension (e.g. ‘the

last period of the previous year’)o The static variables available under Maintain Variables can be used in cube calculationso The dynamic variable @@CUR can be used in the cube calculationso Other dynamic variables, like @@CUR-1, cannot be usedo The order of calculations is important in case of more than 1 calculation in a report

General rules

CXO-Cockpit Cube Calculation

o Conditional statements can be made with the “CASE WHEN” Statement

o There are two ways to query the current contexto [Dimension].[Hierarchy].CurrentMember Checks the current cell contexto <<@@CUR(DIM)>> Checks the POV dimension value

Conditional Statements based on Context

CASEWHEN when_expression1 THEN result1WHEN when_expression2 THEN result2ELSE result3 END

CASE WHEN logical_expressionTHEN result1ELSE result2 END

CXO-Cockpit Cube Calculation

Entity Cube Calculation for GroupTotal using .CurrentMember

Measure Cube Calculation filtering out the current month Sales

Conditional Statements Examples

CASE WHEN [YER].[YER].CurrentMember.Name = "2015" THEN[ENT].[ENT].[Geographical] - [ENT].[ENT].[ASIA]ELSE[ENT].[ENT].[Geographical]END

CASE WHEN [PER].[PER].CurrentMember.Name = "<<@PER_current.Name>>" AND[ACC].[ACC].CurrentMember.Name = “Sales"THEN

NULL ELSE

[MEA].[MEA].[[None]]] END

Use of member containing datao In some cases you want to create a cube calc that is applicable to the complete reporto To do this pick a dimension of which the detail is not used in the reporto This can be an “empty” dimension with data loaded on the None membero Or can be a dimension of which only the Total member is used in the reporto In these cases remember to specify the member on which the data is loaded (in your

source system)o Examples:

o On the None member of the Measure dimensiono On the Total member of the Custom 1 dimension

o General rule: A cube calc should at least contain a member of the same dimension the cube calc is created in

MDX FunctionsMost used function groups for cube calcs are:

o Member Functions returning a memberLike: “.CurrentMember”, “.PrevMember”, “.AllMembers”, “.Children”, “.Properties”

o Numeric Functions returning a numeric value like: “AVG({SET})”, “MAX({SET})”

o Logical Functions returning true or false like: “ISEMPTY([Member])”, “ISLEAF([Member])”

MDX References

o MS Functions library:https://msdn.microsoft.com/en-us/library/ms145970

o MDXpert (good examples):http://www.mdxpert.com/

HFM/ SAP BPC vs Essbase vs SAP BWHFM / SAP BPC MS / Tagetik

o CASE WHEN

[ENT].[ENT].CurrentMember.Name = “Asia”

THEN

……..

o CASE WHEN

[ENT].[ENT].CurrentMember = 1

THEN

……

o Null

o Change order of cube calc by dragging and dropping cube calc

Essbase

o CASE WHEN

[ENTITY].CurrentMember IS [ENTITY].[Asia]

THEN

…….

OR

CASE WHEN

IS([ENTITY].CurrentMember, [ENTITY].[Asia])

THEN

………

o CASE WHEN

[ENT].[ENT].CurrentMember = 1

THEN

……

o Missing

o Change order cube calc by changing order number

SAP BW

o IIF ( InStr([/CPMB/J6D5IJZ PARENTH1].CurrentMember.Name, “Asia“ ) <> 0,….,…..)

o IIF ( InStr([/CPMB/J6D5IJZ PARENTH1].CurrentMember = 1,…..,……)

o Missing

o Change order cube calc by changing order number

Specifics Essbase/ SAPo In CXO we often split Essbase/ SAP dimensionso Example: Period dimension into Period and Viewo In Cube calcs you can specify Period and View members:

o The original member can be usedo Variables can be used

o @@CUR: <<@@CUR(PER), @@CUR(VIW)>>o A specific member of one of the split dimensions can be specified:

<<@PER_Feb, @@CUR(VIW)>>o In case you want to specify one member of the split dimensions, you need to create

variables

Split dimensions

MDX TroubleshootingDebugging

1. Check the MDX as executed in the CXO-Configurator

2. Execute the Query in Management Studio/ Essbase/ SAP MDXTest to test the MDX

ExercisesThree important notes:

o Create your own Menu item as follows: Intials_Training, e.g. ML_TrainingPlace your reports in your own Menu item

o When creating reports during this training, please place your initials at the beginning of a report name. This way we can easily recognize the reports created during this training. E.g.: ML_Profit and Loss

o When creating objects, such as cube calcs and lists, please place your initials at the beginning of a object name. E.g.: ML_ROW - Profit and Loss

Environments exercises

Company Environment

Akzo Nobel training.akzo-nobel.cxo-cockpit.com

Ballast Nedam training.ballastnedam.cxo-cockpit.com

BSN Medical training.bsnmedical.cxo-cockpit.com

Experian training.experian.cxo-cockpit.com

FrieslandCampina training.frieslandcampina.cxo-cockpit.com

KLM training.klm.cxo-cockpit.com

LF Europe training.lfeurope.cxo-cockpit.com

Nidera training.nidera.cxo-cockpit.com

Teeuwissen Holding training.teeuwissenholding.cxo-cockpit.com

User name: company namePassword: password

Exercise 1Calculate Gross Margin %

Instructions

o Calculate Gross Margin %o Your cube calc does work when result

is 0o Cube calc only does not work when

there is no resulto Use Report:

Comma Communications Inc. - KPIs

Exercise 1 Result

[ACC].[ACC].[GrossMargin] / [ACC].[ACC].[Sales]

Calculate Gross Margin %

Entity Cube Calculation using .CurrentMember

Exercise 2

Instructions

o Calculate Total columno Condition:

o For 2015: Asia should be excluded from calculation

o All other years: no exceptiono Create new report, use row list

‘Profit and Loss’ and create own column list

Entity Cube Calculation using .CurrentMember

Exercise 2 Result

CASE WHEN [YER].[YER].CurrentMember.Name = "2015" THEN[ENT].[ENT].[Geographical] - [ENT].[ENT].[ASIA]ELSE[ENT].[ENT].[Geographical]END

Exercise 3Calculation using .currentmember and @@CUR

Instructionso Filtering out the COGS of

the month selected in POVo Rest of the months show

COGSo Think about the dimension

in which you want to build the cube calc.

o Use report:Profit and Loss – 12 Months rolling

Exercise 3 ResultMeasure Cube Calculation filtering out the current month COGSCASE WHEN [PER].[PER].CurrentMember.Name = "<<@@CUR(PER).Name>>" AND[ACC].[ACC].CurrentMember.Name = "COGS"THEN NULL ELSE [MEA].[MEA].[[None]]] END

Exercise 4Use Functions Numeric (AVG) and SET (CrossJoin) function

Instructionso Calculating the average of

Entity children by making use of a Numeric (AVG) and SET (CrossJoin) function

o For instructions on how to use the functions look at the provided references (URLs)

o Crossjoin needs to be used to combine members of 2 different dimensions

o Use your report of Exercise 2

Exercise 4 ResultCalculating the average of children making use of a Numeric (AVG) and SET (CrossJoin) functionAVG(

CROSSJOIN([ENT].[ENT].CurrentMember.Children, [MEA].[MEA].[[None]]]))

Exercise 5Gross Margin Percentage with Filter (Case when)

Instructions:

o Make sure result is null when:o Net Sales is empty o Net Sales is 0o Gross margin% is larger than

500 % or smaller than -500%

Exercise 5 ResultGross Margin Percentage with Filter (Case when):CASE WHEN ISEMPTY([ACC].[ACC].[NetSales])THEN NULLWHEN [ACC].[ACC].[NetSales] = 0THEN NULLWHEN ABS([ACC].[ACC].[GrossMargin] / [ACC].[ACC].[NetSales]) > 5THEN NULLELSE [ACC].[ACC].[GrossMargin] / [ACC].[ACC].[NetSales]END

Exercise 6Calculate % of sales

Instructions:

o Percentage of sales should workfor all rows

o One cube calc should becreated,that works for all scenarios

o Use report EBITDA – As Percentage of Net Sales

Exercise 6 ResultCalculate % of sales

CASE WHEN ISEMPTY (([ACC].[ACC].[NetSales], [MEA].[MEA].[[None]]]))THEN NULL WHEN ([ACC].[ACC].[NetSales], [MEA].[MEA].[[None]]]) = 0THEN NULLWHEN ABS(([ACC].[ACC].CurrentMember, [MEA].[MEA].[[None]]]) / ([ACC].[ACC].[NetSales],[MEA].[MEA].[[None]]]))>5 THEN NULL ELSE ([ACC].[ACC].CurrentMember, [MEA].[MEA].[[None]]]) / ([ACC].[ACC].[NetSales],[MEA].[MEA].[[None]]]) END

Exercise 7Filter on property

Instructions:

o Filter the “Income” accounts outof your list by using property “ACC Type” (make them empty)

o Create a report:o Use row list: KPI for Home

pageo Use column list: Periods side

control 12 months

Exercise 7 ResultFilter on property

CASE WHEN[ACC].[ACC].CurrentMember.Properties("ACC Type") = "Income" THENNULLELSE[MEA].[MEA].[[None]]]END

Exercise 8Use of text in cube calc

Instructions:

o When actuals are lower than 2.5 mln, then SUNSETTED should display

o When actuals are lower than 4mln, then EMERGING should display

o In all other cases FLAGSHIP should display

o Use report: Product Categories

Exercise 8 ResultUse of text in cube calc

CASE WHEN [CAT].[CAT].[Actual] < 2500000 THEN 'SUNSETTED'WHEN [CAT].[CAT].[Actual] < 4000000 THEN 'EMERGING'ELSE ‘FLAGSHIP’

END

CXO-Cockpit MDX Listso MDX Lists

o MDX Lists leveraging all of the SET related MDX functions to create a Member list,o with all of the dynamics of hierarchies, ranges, exclusions, o while still having the ability to format the lists to the end users preferences

o MDX Functions that can be used: AllMembers, Descendants, Range, Top/Bottom – Count, Percent or Sum , CrossJoin, etc…

o Example 1{Crossjoin(Descendants([ENT].[ENT].[Geographical],1,self),{[ACC].[ACC].[Sales]}),Crossjoin(Descendants([ENT].[ENT].[Geographical],1,self),{[ACC].[ACC].[Profit]})}

Direct descendants of Comma Communications for Sales and direct descendants of Comma Communications for Profit

o Example 2TopCount(Descendants(<<@@CUR(ENT)>>,,leaves),5, [ACC]. [ACC].[Profit])

Top 5 Entity members of base member of POV entity selected for the Account Profit

o Conditional Rules for formatting o Custom Description, Suppression , Formats, etc…

HFM vs EssbaseHFM / SAP / Tagetik

o Base members:Descendants(<<@@CUR(ENT)>>,,leaves)

o Case when"<<@@CUR(ENT).name>>" = “Asia“THEN……

Essbase

o Base members:<<@@CUR(ENT)>>.levels(0).members

o Case when<<@@CUR(ENT)>> IS [ENT].[ENT].[Asia]THEN……

CXO-Cockpit MDX Lists

oThe different dimensions you specify in your lists need to be included in the MDX lists

oMDX Lists are created by a SET or Tuple Set expression:in your list always use curly brackets {}

oMDX Lists can make use of Cube Calculations

Basic MDX Lists

Exercise 9Column list containing all years and

quarters

Instructions:

o Create a list with in the columnsallyears and all quarters

o Make sure that only thecolumns with data display(make use of rule)

o Create new report and use report list ‘Profit and Loss’

Exercise 9 Result

{[YER].[YER].AllMembers} * {[PER].[PER].[[Year]]].Children}

Column list containing all years and quarters

{Crossjoin([YER].[YER].AllMembers,[PER].[PER].[[Year]]].Children)}

Or

Exercise 10Row list with Except

Instructions:

o Create a list with the children of entity Geographical

o Filter out Asiao In case of empty entity:

suppress row(by making use of a rule)

o Use column list: Periods side control 12 months

Exercise 10 ResultRow list with Except

Except(Descendants([ENT].[ENT].[Geographical],1,self),{[ENT].[ENT].[ASIA]})

Exercise 11Row list with TopCountfunction

Instructions:

o Create a list containing thetop 25 business driversbased on:o Productso Customerso Sales offices (entities)

o Use column list: 05 12 M + Total columns

Exercise 11 ResultRow list with TopCount function

{TOPCOUNT(CROSSJOIN(DESCENDANTS([a01].[a01].[TotalProducts],,LEAVES),DESCENDANTS([a02].[a02].[TotalCustomers],,LEAVES),DESCENDANTS([ENT].[ENT].[Geographical],,LEAVES)), 25,[MEA].[MEA].[[None]]])}

Thank you