0

I am new to MDX Queries. I am currently trying to calculate the percentage of orders cancelled. The status code for cancelled orders is 3. But it's proofing so difficult for me. I've searched online for hint but still not able to figure out. The code below calculate the number of Cancelled orders correctly but I need to then find out the percentage of the cancelled orders Here's my code below: Will really appreciate any help.

SELECT NON EMPTY { [Measures].[Order Group Count] } ON COLUMNS FROM (
  SELECT ( { [Order Status].[Status Code].&[3] } ) ON COLUMNS FROM [NCube]) 
    WHERE ( [Order Status].[Status Code].&[3] ) 
      CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, 
      FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Many thanks in Advance

Jan B.
  • 6,030
  • 5
  • 32
  • 53

1 Answers1

0

You'll need to create a calculated Measure in your script, or alternatively you could create this as a calculation within your Cube. The following should get you the answer from a script perspective:

WITH MEMBER Measures.[CancelledOrders] AS SUM([Order Status].[Status Code].&[3],[Measures].[Order Group Count])

MEMBER Measures.[PercentCancelled] AS DIVIDE(Measures.[CancelledOrders], [Measures].[Order Group Count])

Select {Measures.[PercentCancelled]} ON COLUMNS FROM [NCube]

Hopefully this should get you started.

MrHH

MrHappyHead
  • 442
  • 3
  • 8