+ Reply to Thread
Results 1 to 2 of 2

Thread: Creating a Pivot Table from MDX

  1. #1
    Registered User
    Join Date
    10-08-2010
    Location
    Washington, USA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Creating a Pivot Table from MDX

    We are converting an existing BI application to Excel pivot tables. Does anyone know of a way to create a pivot table from an MDX statement? I tried this macro:

    Sub SetPivotMDX()

    Dim sourceData As Worksheet
    Set sourceData = Worksheets("TestData")

    Dim strName As String
    strName = Left(sourceData.Range("B2").Value, 5)

    Dim strFormula As String

    ' get the MDX for the pivot table
    strFormula = sourceData.Range("B3").Value

    Dim WS As Worksheet
    Set WS = Sheets.Add
    WS.Activate
    WS.Name = strName

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, sourceData:= _
    "TestData!R2C1:R3C3", Version:=xlPivotTableVersion10).CreatePivotTable _
    TableDestination:="JI026!R3C1", TableName:="PivotTable1", DefaultVersion _
    :=xlPivotTableVersion10

    WS.Select

    WS.PivotTables("PivotTable1").MDX = strFormula

    End Sub

    But I've since found that the pivotTables.MDX property is read-only.

    Anyone have any ideas on how to do this?

  2. #2
    Forum Guru pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2010
    Posts
    5,151

    Re: Creating a Pivot Table from MDX

    Hi juway,
    Welcome to the forum.Please take a few minutes to read the forum rules, and then amend your thread title accordingly.
    regards pike

    If the solution helped please donate
    here to the RSPCA

    Sites worth visiting;

    J&R Solutions - royUK

    AJP Excel Information - Andy Pope

    Spreadsheet Toolbox

    VBA for smarties - snb

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0