ClientName TaxReturnTypeName Volume
client1 ReturnEI 10
client2 ReturnEI 20
client3 ReturnEI 30
client1 ReturnEC 15
client2 ReturnEC 20
client2 ReturnEP 70
client3 ReturnET 90
Expected Output:
Type Sum
ReturnEI 60
ReturnEC 35
ReturnEP 70
ReturnET 90
$file = "c:\test\ReportVolumes.csv" # here goes the path and name of the excel file.
$report = import-csv $file
# $report | Group-Object taxreturntypename |
# Select-Object @{n='Type';e={$_.Group[0].taxreturntypename}},
# @{n='Volume';e={$_.Group[0].Volume}}
$Result = ForEach ($Type in ($report | Group taxreturntypename))
{ [PSCustomObject]@{
Type = $Type.Name
Sum = ($Type.Group | Measure-Object Volume -Sum).Sum
}
}
$Result | Export-Csv "C:\test\out.csv"
No comments:
Post a Comment