PivotTable.MDX property (Excel)

Returns a String indicating the Multidimensional Expression (MDX) that would be sent to the provider to populate the current PivotTable view. Read-only.

Syntax

expression.MDX

expression A variable that represents a PivotTable object.

Remarks

Querying this value for a non-Online Analytical Processing (OLAP) PivotTable, or when there is no PivotTable view (no data items), will return a run-time error.

Example

This example returns the MDX string for the PivotTable. It assumes that a PivotTable exists on the active worksheet.

Sub CheckMDX() 
 
 Dim pvtTable As PivotTable 
 
 Set pvtTable = ActiveSheet.PivotTables(1) 
 
 MsgBox "The MDX string for the PivotTable is: " & _ 
 pvtTable.MDX 
 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.