When you use the Excel API PivotTable.CalculatedMembers.Add to add a session calculated member to a PowerPivot PivotTable, certain MDX expressions do not work. For example, if you add a dimension calculated member that uses the Aggregate MDX function, the PivotTable displays this error message:
ERROR - CALCULATION ABORTED: MdxScript(Sandbox) (4, 48) The expression invokes an object that was defined by using an MDX calculated member or script. Such objects are not supported in DAX expressions.
An example PowerPivot workbook showing the error is attached. And this is discussed more here: