I am working on getting some data out of CSV file with a script and have no idea to solve the most important part - I have an array with few hundred lines, there are about 50 Ids in those lines, and each Id has a few different services attached to it. Each line has a price attached.
I want to group lines by ID and Service and I want each of those groups in some sort of variable so I can sum the prices. I filter out unique IDs and Services earlier in a script because they are different all the time.
Some example data:
$data = @(
[pscustomobject]@{Id='1';Service='Service1';Propertyx=1;Price='5'}
[pscustomobject]@{Id='1';Service='Service2';Propertyx=1;Price='4'}
[pscustomobject]@{Id='2';Service='Service1';Propertyx=1;Price='17'}
[pscustomobject]@{Id='3';Service='Service1';Propertyx=1;Price='3'}
[pscustomobject]@{Id='2';Service='Service2';Propertyx=1;Price='11'}
[pscustomobject]@{Id='4';Service='Service1';Propertyx=1;Price='7'}
[pscustomobject]@{Id='2';Service='Service3';Propertyx=1;Price='5'}
[pscustomobject]@{Id='3';Service='Service2';Propertyx=1;Price='4'}
[pscustomobject]@{Id='4';Service='Service2';Propertyx=1;Price='12'}
[pscustomobject]@{Id='1';Service='Service3';Propertyx=1;Price='8'})
$ident = $data.Id | select -unique | sort
$Serv = $data.Service | select -unique | sort
All help will be appreciated!