Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

PowerShell Excel Filter Pivot Table

$
0
0

I have created a pivot table via COM automation in Powershell, but I'm having difficulty determining how to apply a filter. Any ideas? Below is the part of my code where I am trying to filter:

#Excel Variables
$xlPivotTableVersion14 = 3
$xlDatabase = 1
$xlColumnField = 2
$xlRowField = 1
$xlDataField = 4
$xlAverage = -4106
$xlLastCell = 11
$xlCaptionContains = 21

$PivotTable = $Workbook.PivotCaches().Create($xlDatabase,"Data",$xlPivotTableVersion14)
$PivotTable.CreatePivotTable("PivotTables!R1C1","MemPivot") | Out-Null
Start-Sleep -Milliseconds 500
$PivotFields = $PivotWS.PivotTables("MemPivot").PivotFields("Date")
$PivotFields.Orientation = $xlColumnField
$PivotFields.Position = 1
$PivotFields = $PivotWS.PivotTables("MemPivot").PivotFields("ClusterName")
$PivotFields.Orientation = $xlRowField
$PivotFields.Position = 1
$PivotFields.PivotFilters.Add($xlCaptionContains,"Non-Prod")



Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>