How to define compound metrics in MDX Cubes Please refer to the following MicroStrategy technical notes for documentation about creating compound metrics. MDX Metrics TN15870 TN570081x-2493 MDX Metrics TN16057 TN520081x-2345 MDX Metrics TN16095 TN520081x-2342 MDX Metrics TN16100 TN520081x-2343 MDX Metrics TN16096 TN520081x-2344 MDX Metrics TN16402 TN5200810-2354 MDX Metrics TN16406 TN5200810-2355 MDX Metrics TN16517 TN520081X-2366 MDX Metrics TN18396 TN520081X-2416 MDX Metrics TN18206 TN520081X-2411 MDX Metrics TN18201 TN520081X-2410 MDX Metrics TN31816 MDX Metrics TN19660 TN530081X-2862 MDX Metrics TN19083 TN520081X-2428 MDX Metrics TN30355 MDX Metrics TN19705 TN520081X-2433 New feature in MicroStrategy Desktop 8.1.0: Compound metrics for OLAP Cube data sources How to create customized metric expressions for OLAP Cube data sources in MicroStrategy Engine 8.1.x How to write a custom metric formula in MDX to ignore grouping on a cube dimension in MicroStrategy Engine 8.1.x How to write a custom metric formula in MDX to filter on an attribute in MicroStrategy Engine 8.1.x How to write a custom metric formula in MDX to implement a transformation in MicroStrategy Engine 8.1.x How to use smart compound metrics to aggregate report-level metric values at a higher level in OLAP Cube data sources in MicroStrategy Engine 8.1.0 How to perform multi-level aggregation in custom MDX expressions for OLAP Cube data sources in MicroStrategy Engine 8.1.0 How to perform 'Rolling X days/week/months/etc.' analysis using custom MDX expressions against OLAP cube data sources in MicroStrategy 8.1.x Fundamentals of MDX data processing for custom MDX formulas in MicroStrategy Engine 8.1.x and newer How to write a custom MDX formula to rank report rows in OLAP Cube reports in MicroStrategy Engine 8.1.x How to perform ranking in the Analytical Engine for OLAP Cube (MDX) reports in MicroStrategy Engine 8.1.x How to enable custom MDX metrics for dynamic aggregation in MicroStrategy OLAP Services 9.0.x How to create a pie chart graph based on the rank of a metric for OLAP Cube data sources in MicroStrategy 8.1.x? How to write a custom MDX formula to simulate beginning or ending grouping (nonaggregatable metrics) in MicroStrategy Engine 8.1.x How to optimize custom MDX expressions using queryscoped named sets in MicroStrategy Engine 9.x How to build metric qualifications using different metrics and the logic operators AND and OR when reporting against SAP cubes in MicroStrategy Engine 8.1.x <<Add discussion about metrics vs. KFs>> MDX Cubes include metrics which are imported from the InfoCube (not editable) but you can also define new “compound metrics”. You can edit a cube by opening the MDX Cube Catalog but also by editing the cube from the Data Explorer. You can define new compound metrics using existing metrics or by defined a custom MDX statement. Note: when working with cube editor, enable options Display All Columns and Show Technical names. Compound metrics are defined at the MDX cube level and shared for all reports based on the same MDX cube. They are not shared across cubes, so if you need to define same metrics then you need to create them in each MDX cube. Following sections showcase different examples of compound metrics. InfoCube: Orion Tutorial (P_ORION) Query: SAP BW – Query for MDX Metrics (DEMO_MDXMETRICS_01) TN15870 Standard Compound Metrics Profit Margin You can define smart To insert compound metrics in reports, open Metrics folder then new folder “Compound Metrics” Here is a report using the new compound metric You can define MDX metrics by using a custom MDX statement. This option will enable you to define conditional metrics, transformation metrics, etc. In this case, you need to write a MDX statement to support the different scenarios. It is recommended writing MDX statements using Notepad and then copying definition to the metric editor. To get all the source technical names, you can use the cube editor and obtain values from the object properties. Edit cube and select objects and RMC to open properties Copy the technical name for all objects Same process for Metrics Finally, you will have a file with all technical names that you may require for building MDX statements To define a MDX metric you need to write a custom MDX statement that will be passed to the Cube Source. If you enclose a formula with double quote marks then it will be treated as a passthrough formula You can write in notepad and then copy it to the metric editor "([Measures].[Revenue], [P_CAT].[All])" You can ApplySimple("sum({#0}, [Measures].[2ADGUNXJMK81DUC89YBTBKB4P])", also define ?[Select Year for MDX Metric]) another MDX metric In this case, you should create first a prompt for Year using an ApplySimple Create a report an use new metrics Here is the final report TN16100 MDX metrics to filter in an attribute Create following metrics to filter on one single attribute element and several elements: "([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [P_CAT].[2])" "Aggregate({[P_CAT].[1], [P_CAT].[3]}, [Measures].[2ADGUNXJMK81DUC89YBTBKB4P]" To get the values to include in the syntax, you can create a report and show ID form and copy those values (export report results to Excel to copy expression). Fails because syntax was incorrect Report: Report with MDX metrics to filter on an attribute - TN16100 Job: 1413 Status: Execution failed Error: SQL Generation Complete QueryEngine encountered error: ExecQuery failed. MDX Execution failed. Error type: JCO layer error. JCOStatement.executeQuery failed. java.lang.Exception: [JCO] Error during MDX Query Execution [JCO] Error during Bapi Execution: Invalid MDX command with ' at com.microstrategy.Database.JCO.JCOStatement.executeQuery(Unknown Source) . Connection String: N/A;. Connection String: N/A;. SQL Statement: with set [dim0_select_members] as '{[P_REGION].[LEVEL01].members}' member [Measures].[FreeForm_0] as '([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [P_CAT].[2])' member [Measures].[FreeForm_1] as 'Aggregate({[P_CAT].[1], [P_CAT].[3]}, [Measures].[2ADGUNXJMK81DUC89YBTBKB4P]' select {[Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [Measures].[FreeForm_0], [Measures].[FreeForm_1]} on columns, non empty [dim0_select_members] on rows from [P_ORION/DEMO_MDXMETRICS_01] cell properties CELL_ORDINAL, FORMATTED_VALUE, VALUE, FORMAT_STRING .. Error in Process method of Component: QueryEngineServer, Project SAP BW & MicroStrategy Tutorial, Job 1413, Error Code= -2147212544. Starting Time: 13:14:22 "Aggregate({[P_CAT].[1], [P_CAT].[3]}, [Measures].[2ADGUNXJMK81DUC89YBTBKB4P]" is missing ) at the end Correct formula is "Aggregate({[P_CAT].[1], [P_CAT].[3]}, [Measures].[2ADGUNXJMK81DUC89YBTBKB4P])" When building MDX metrics sometimes is a good strategy to test syntax first using MDX Test as it will allow you to modify the MDX statement what is the correct syntax, without having to edit metric and then run report. Copy previous MDX statement over MDXTest transaction in SAP GUI Edit syntax and add “)”. Now it works. Edit MDX Metric to correct problem Add another MDX metric to filter on several attributes directly editing one of the You can modify one of the MDX metrics and test it before adding the compound metric: "([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], MDX Metrics [P_CAT].[2], [P_YEAR].[2007])" In this case, you define a conditionality on Category Electronics (ID = 2) and Year 2007 by including both conditions in the statement. Create compound metric Final report You can write a custom mdx metric expression to specify the level which a metric will be calculated Member [All] group for all members in the dimension For example, "([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [P_REGION].[All])" Now you can create a % Total metric You can define transformation metrics; some operate with member operators and other use time functions so they require a time hierarchy. You can use PrevMember to calculate previous month for a characteristic that is not in the Time dimension Set functions will only work with a standard SAP time dimension as Calendar Year or Fiscal Year Following syntaxes will work "([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [P_MONTH].CurrentMember.Prevmember)" For the target query, following syntax will not work "sum(YTD([P_MONTH].CurrentMember), [Measures].[2ADGUNXJMK81DUC89YBTBKB4P])" Previous month "([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [P_MONTH].CurrentMember.Prevmember)" Previous month "([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [P_MONTH].CurrentMember.Lag(1))" Same month last year "([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [P_MONTH].CurrentMember.Lag(12))" Last 3 months "Aggregate({[P_MONTH].CurrentMember.Lag(1), [P_MONTH].CurrentMember.Lag(2), [P_MONTH].CurrentMember.Lag(3)}, [Measures].[2ADGUNXJMK81DUC89YBTBKB4P])" Next month "([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [P_MONTH].CurrentMember.Nextmember)" 3 months lead "([Measures].[2ADGUNXJMK81DUC89YBTBKB4P], [P_MONTH].CurrentMember.Lead(3))" Here is a report with all those metrics For set functions you need a time hierarchy as the standards: Calendar Year – Calendar Year/Quarter – Calendar Year/Month – Calendar Day Fiscal Year – Fiscal Year/Quarter – Fiscal Year/Month – Fiscal Day You will use a different Query which contains Calendar Time hierarchy. InfoCube: Date Call Center Sales (DAY_CTR) Query: SAP BW - Query for MDX Metrics & Transformations (DEMO_MDXMETRICS_02) Please refer to technote TN16096 for detail discussion: Define MDX metrics for Calendar Year/Month Revenue YTD - "sum(YTD([0CALMONTH].CurrentMember), [Measures].[6ITI6HTBAIMH2DRKVPBZDUCM1])" Rolling 3 months "sum(LastPeriods(3,[0CALMONTH].CurrentMember), [Measures].[6ITI6HTBAIMH2DRKVPBZDUCM1])" Next 3 months "sum(LastPeriods(-3,[0CALMONTH].CurrentMember), [Measures].[6ITI6HTBAIMH2DRKVPBZDUCM1])" Revenue same month previous Year "([Measures].[6ITI6HTBAIMH2DRKVPBZDUCM1],ParallelPeriod([0CALYEAR], 1, [0CALMONTH].CurrentMember))" Rev. same month LY (lag) "([Measures].[6ITI6HTBAIMH2DRKVPBZDUCM1], [0CALMONTH].CurrentMember.Lag(12))" Report Define MDX metrics for Calendar Day Report Revenue YTD - "sum(YTD([0CALDAY].CurrentMember), [Measures].[6ITI6HTBAIMH2DRKVPBZDUCM1])" Revenue QTD - "sum(QTD([0CALDAY].CurrentMember), [Measures].[6ITI6HTBAIMH2DRKVPBZDUCM1])" Revenue MTD - "sum(MTD([0CALDAY].CurrentMember), [Measures].[6ITI6HTBAIMH2DRKVPBZDUCM1])" Revenue WTD - "sum(WTD([0CALDAY].CurrentMember), [Measures].[6ITI6HTBAIMH2DRKVPBZDUCM1])"