dfinke / ImportExcel

PowerShell module to import/export Excel spreadsheets, without Excel
https://www.powershellgallery.com/packages/ImportExcel/
Apache License 2.0
2.47k stars 398 forks source link

Pivot Sort #1307

Closed dfinke closed 1 year ago

dfinke commented 1 year ago

Discussed in https://github.com/dfinke/ImportExcel/discussions/1306

Originally posted by **RoYoMi** November 12, 2022 I have created a pivot table but it don't see a way to make it sort the output by the Grand Total field. In Excel I can manually right click the a total field and choose sort. Here is my setup: ``` $Excel = $Output.RawData ` | Select-Object @{n="Date"; e={$_.Date | Get-Date}}, @{n="DateYM"; e={$_.Date | Get-Date -Format "yyyy`nMMM"}}, ComputerName, DisplayName, Commandlet, ModuleVersion, Event, FullCommand ` | Export-Excel $ExcelFile @ExportExcelOptions -Passthru $PivotTableOptions = @{ ExcelPackage = $Excel PivotTableName = "ByCommand" SourceWorkSheet = $Excel.Sheet1 PivotRows = "Commandlet" PivotData = @{"Commandlet" = "Count"} PivotColumns = @("DateYM") PivotTotals = "Both" PivotTableStyle = "Light16" } $pt = Add-PivotTable @PivotTableOptions -PassThru ``` That code creates this: ![image](https://user-images.githubusercontent.com/8366040/201506050-e48dd87e-f0c6-47c0-874f-31023fe73a9f.png) I found this teaser in [v5.3](https://github.com/dfinke/ImportExcel/blob/7c473d1fb6faccf7722e7c3219af891c483d3b4c/README.original.md) where it talks about sort on pivot tables, but I can't figure it out. Did I miss something in the docs? Or is this even possible?
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.