VBA, OLAP cube pivot : refer to parent of selected filter?

srgexcel

New Member
Joined
Nov 20, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have a data cube pivot table Period split by [Fin Year - WK - Date] (financial year - week number - date).

I filter the table by a date period: using VBA I am selecting a 7 day period by date, based on a cell holding a date.
I am not selecting the week number as this is never referred to or calculated by the end users.

VBA Code:
   Sheets("z").PivotTables("y").CubeFields(89).EnableMultiplePageItems _
        = True
    Sheets("z").PivotTables("y").PivotFields( _
        "[Period].[Fin Year - WK - Date].[Date]").VisibleItemsList = Array( _
        "[Period].[Fin Year - WK - Date].[Date].&[" & Format(Cells(2, 3).Value, "yyyy-mm-dd") & "T00:00:00]", _
        "[Period].[Fin Year - WK - Date].[Date].&[" & Format(Cells(2, 3).Value + 1, "yyyy-mm-dd") & "T00:00:00]", _
        "[Period].[Fin Year - WK - Date].[Date].&[" & Format(Cells(2, 3).Value + 2, "yyyy-mm-dd") & "T00:00:00]", _
        "[Period].[Fin Year - WK - Date].[Date].&[" & Format(Cells(2, 3).Value + 3, "yyyy-mm-dd") & "T00:00:00]", _
        "[Period].[Fin Year - WK - Date].[Date].&[" & Format(Cells(2, 3).Value + 4, "yyyy-mm-dd") & "T00:00:00]", _
        "[Period].[Fin Year - WK - Date].[Date].&[" & Format(Cells(2, 3).Value + 5, "yyyy-mm-dd") & "T00:00:00]", _
        "[Period].[Fin Year - WK - Date].[Date].&[" & Format(Cells(2, 3).Value + 6, "yyyy-mm-dd") & "T00:00:00]")

The 7 days are correctly selected in the filter, but the 'parent' week number remains partially selected.
1700531089346.png

This results in a measure not populating as the week dimension is not selected.

Is there a method in VBA to select the parent of a filter? ie given 30/11/23, select the parent which happens to be Week 19.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Sorry to bump.. any ideas or confirmation it is not possible?
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,958
Members
449,096
Latest member
Anshu121

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