I have a table that looks like this:
Year | Month | Customers | Country |
---|---|---|---|
2022 | January | 12 | Argentina |
2022 | January | 4 | Australia |
2022 | January | 6 | Brazil |
2021 | December | 8 | Argentina |
2021 | December | 4 | Australia |
2021 | December | 2 | Brazil |
2021 | November | 12 | Argentina |
2021 | November | 4 | Australia |
2021 | November | 14 | Brazil |
I want to consolidate the year and month columns, and transpose the rest of the data for a result that looks like this:
Year | Month | Argentina | Australia | Brazil |
---|---|---|---|---|
2022 | January | 12 | 4 | 6 |
2021 | December | 8 | 4 | 2 |
2021 | November | 12 | 4 | 14 |
Is there any way to do this in Google Sheets?
CodePudding user response:
Try below QUERY()
function.
=QUERY(A1:D10,"select A, B, min(C) group by A,B pivot D order by A DESC")
CodePudding user response:
Use this formula
=QUERY(QUERY({A1:D}, " Select * Where Col1 is not null "),
"Select Col1, Col2, min(Col3) group by Col1,Col2 pivot Col4 order by Col1 Desc")