Javier
Javier

Reputation: 831

VBA CubeField filter

For a normal pivot table I'm doing

For Each item In .PivotTables("table1").PivotFields("field1").PivotItems
    If item.Value = "asdf" Then
        item.Visible = True
    Else
        item.Visible = False
    End If
Next item

where field1 is not a page field. Can I do the same in a data model pivot table? I've read about CubeFields but I don't have PowerPivot installed.

Upvotes: 1

Views: 1137

Answers (1)

Javier
Javier

Reputation: 831

No documentation or forum or videotutorial could drive me to this answer, so I share it for the sake of future humanity.

.PivotTables("table1").CubeFields( _
    "[MyDB].[field1]").CreatePivotFields
.PivotTables("table1").PivotFields( _
    "[MyDB].[field1].[field1]").VisibleItemsList = Array( _
    "[MyDB].[field1].&[asdf])

Replace MyDB, table1, field1 and asdf with your own objects.

Upvotes: 1

Related Questions