0
votes

I am able to use the QUERY function to get rows from another sheet but if I try to use ORDER BY I get nothing. Oddly, if I do ORDER BY with DESC it does work.

My example sheet is at https://docs.google.com/spreadsheets/d/18I-GsBzTLtuxwh8sdqeeLb0kLHMc8Z3EpFcN6s17CSU/edit?usp=sharing.

This is my QUERY function that only returns the header row:

=query(source!A:C, "SELECT A, B, C ORDER BY C")

Both of these below work:

=query(source!A:C, "SELECT A, B, C")
=query(source!A:C, "SELECT A, B, C ORDER BY C DESC")

The first one returns all rows and the second one returns all rows sorted on column C.

Am I missing something?

1

1 Answers

2
votes

Ordering by C is placing your values at the bottom since the blank cells have a value that places them higher up. For example, if I reduce my rows to only 20 you will see your formula does work, it's just that they are at the bottom:

enter image description here

Try this formula instead: =QUERY(source!,"SELECT A,B,C WHERE A IS NOT NULL ORDER BY C")

That filters out blank cells and should order the value how you are expecting it too.

enter image description here