Pivot Table Question.
g-pearl opened this issue · 2 comments
I am trying to automate a pivot table creation but I am having issues matching what happens in excel when done manually.
This is my code.
`$excel_package = Open-ExcelPackage -Path "D:\File_$(get-date -Format MM-dd-yyyy).xlsx"
Add-Worksheet -ExcelPackage $excel_package -WorksheetName "Exec Summary" -MoveToStart -Activate | Out-Null
$pivotTableParams_PerDay_Usage = @{
PivotTableName = "Usage"
Address = $excel_package."Exec Summary".cells["A5"]
SourceWorkSheet = $excel_package."Network Data Usage"
PivotRows = @("SRUM ENTRY CREATION")
PivotData = @{"Bytes Sent" = "SUM" ; "Bytes Received" = "SUM"}
PivotTableStyle = 'Light21'
IncludePivotChart = $False
}
Add-PivotTable @pivotTableParams_PerDay_Usage -PassThru | Out-Null
#$excel_package.Workbook.Worksheets['Exec Summary'].cells["A1"].Value = "Usage"
Close-ExcelPackage -ExcelPackage $excel_package`
I want the finally pivot table to be like this.

How do I get the ROWS to have the "Months (SRUM ENTRY CREATION)" and "Days (SRUM ENTRY CREATION)" entries?
Thanks for any guidance you can provide.
Good question!
See if this helps, if not, let me know.
This did help. The pivot table and the definition (Filters/Columns/Rows/Values section) does not exactly match but it is close enough that this will save a lot of time. Thanks for the time and as always GREAT MODULE - COULD NOT LIVE WITHOUT IT!!!