mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Improve measure calculations
This commit is contained in:
@@ -14,17 +14,28 @@ function Invoke-Sum {
|
|||||||
|
|
||||||
if(!$key) {$key="[missing]"}
|
if(!$key) {$key="[missing]"}
|
||||||
|
|
||||||
$value = $item.$measure
|
if(!$h.ContainsKey($key)) {
|
||||||
if($value -is [string] -or $value -is [System.Enum]) {
|
$h.$key=[ordered]@{}
|
||||||
$value = 1
|
|
||||||
}
|
}
|
||||||
$h.$key+=$value
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($entry in $h.GetEnumerator()){
|
foreach($m in $measure) {
|
||||||
[PSCustomObject]@{
|
$value = $item.$m
|
||||||
Name=$entry.key
|
if($value -is [string] -or $value -is [System.Enum]) {
|
||||||
$measure=$entry.value
|
$value = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$h.$key.$m+=$value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($entry in $h.GetEnumerator()){
|
||||||
|
|
||||||
|
$nh=[ordered]@{Name=$entry.key}
|
||||||
|
|
||||||
|
foreach ($item in $entry.value.getenumerator()) {
|
||||||
|
$nh.($item.key)=$item.value
|
||||||
|
}
|
||||||
|
|
||||||
|
[pscustomobject]$nh
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user