Update OLAP Pivot Table with Data Validation

Claymationator

Well-known Member
Joined
Sep 26, 2006
Messages
705
I have an OLAP cube that is tied to tables in our data warehouse. I am trying to create some reports that will allow the user to select certain variables in the summary sheet and manipulate the data that is shown. Because of the large amount of data I am not able to show all of the variables in the actual pivot table (Excel doesn't have enough resources to show the data.) So, what I have is data validation on the summary page where the user can select the store #, and I want that to update the OLAP cube.

I know that there is code out there to update regular pivot tables in Excel, but that seems to only work when the source data is housed in Excel, but not for OLAP cubes. The data that I have seen (http://www.contextures.com/excelfiles.html#Pivot) is like this:

Rich (BB code):
Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)

Dim ws As Worksheet
Dim pt As PivotTable
Dim pi As PivotItem
Dim strField As String

strField = "Store Club Number"

On Error Resume Next
Application.EnableEvents = False
Application.ScreenUpdating = False

    If Target.Address = Range("B2").Address Then
        
        For Each ws In ThisWorkbook.Worksheets
            For Each pt In ws.PivotTables
                With pt.PageFields(strField)
                    For Each pi In .PivotItems
                        If pi.Value = Target.Value Then
                            .CurrentPage = Target.Value
                            Exit For
                        Else
                            .CurrentPage = "(All)"
                        End If
                    Next pi
                End With
            Next pt
        Next ws
    
    End If

Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub

I have tried this, but it doesn't update anything (hence the post here.) I went in and manually recorded me making a change, but I don't follow the syntax very well when it is dealing with the OLAP cubes, so I am not sure how I would change this to be similar to the code posted above:

Recorded Code:

Rich (BB code):
Sub Testing()

    ActiveSheet.PivotTables("PivotTable3").PivotFields( _
        "
.[Store Number].[Store Number]").VisibleItemsList = _ Array("
.[Store Number].&[5295]") End Sub​


The variable that I changed is the "Store Number", "5295" in this case. So, I have a list of all of the stores and I want the pivot to update based on the selection that the user makes in that dropdown.

Any help is appreciated.​
 
What OLAP database are you using?

You may be able to connect directly to it with Excel using an MDX Provider.
 
Upvote 0
The data is already in Excel in a pivot table that is connecting to a SQL database. So I have the pivot formatted as I need it in Excel, but I can't display all of the stores in Excel as there is too much information for it to show. So, I have to make the selection in the report filter, and I am trying to automate that based on an input in another cell (Data Validation List.)

That is where I am having trouble, I can use VBA to modify other pivot tables where the pivot's source data is in Excel and not housed externally. However, with the OLAP cube in Excel, the pivots behave a bit differently, and I am not sure how to manipulate it with VBA.
 
Upvote 0
Depending on your data source, there may be a driver that would help connect directly to excel (allowing you to filter beforehand).
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top