Hey everyone,
I'm working with a query that generates the following output:
```
Date Title Usage
20251109 DeptA 800000
20251109 DeptB 700000
20251109 DeptC 600000
20251109 DeptD 850000
```
For my Excel export, I need the data to be reformatted into:
`DeptA DeptB DeptC DeptD`
`800000 700000 600000 850000`
I'm using the Export-Excel command from the ImportExcel Module for exporting. How can I manipulate the array to achieve this format for my output? Sorry for the poor formatting, and thanks in advance for your help!
2 Answers
Could you share what you've tried so far? It might help narrow down the solution.
Have you posted any code? I'm pretty familiar with the Import-Excel module and I think this could be a simple sorting issue.
All I’m doing is taking the output from the query above and exporting it like this:
```
$resultset | export-excel "c:tempmyoutput.xlsx" -worksheetname "Usage"
```

Not much, just trying to reformat the result like this:
```
$swappedArray = @()
foreach ($item in $resultset) {
$swappedArray += [PSCustomObject]@{
$item.Title = $item.Usage
}
}
```
But the result isn’t quite what I expected.