Home > OS >  How do I sort a data range but only return one column? (Sheets)
How do I sort a data range but only return one column? (Sheets)

Time:11-19

I have a data range in Google Sheets where I want to sort the data by column B, but only return column A. If it matters, column A is a string, column B is integers.

Using =SORT(A1:B10,2,FALSE) returns both columns A and B, sorted by column B...but I only want it to return column A.

I've also tried: =QUERY((SORT(A1:B10,2,FALSE)),"select *") <- does exactly the same as sort, tried just for testing =QUERY((SORT(A1:B10,2,FALSE)),"select col1") <- #value error =QUERY((SORT(A1:B10,2,FALSE)),"select A") <- #value error (also tried "select A:A" and "select A1:A10") =QUERY((SORT(A1:B10,2,FALSE)),"select Stat") <- #value error

I've also tried all of the above, but starting with =QUERY(A1:B10,SORT(...

Am I using QUERY wrong? Is SORT not what I want? I could just use SORT in a hidden part of the sheet, then reference the column I want but that feels cheaty, I want to know if there's a way to do what I want to do.

CodePudding user response:

You can set in the first part the column you want to be returned, then the column you want to be sorted with, and then if it's ascending or not (you can then add other columns, obviously. They don't need to be included nor contiguous, but of the same size). Try this:

=SORT(A1:A10,B1:B10,FALSE)
  • Related