google-sheetsformulaflatten

How to use query and flatten formula in google sheets with null & desc


I'm trying to get column A by order of 'desc' based off whether column B is empty. I would like all of column A cells that have empty column B cells to be at the bottom. If possible without any helper cells Sample image

Please see Sample sheet Sample Sheet


Solution

  • You can try with sorting instead of QUERY:

    =SORT(A2:A,B2:B<>"",0)
    

    And insert it into QUERY or TOCOL to get rid of the blank values:

    =QUERY(SORT(A2:A,B2:B<>"",0),"WHERE Col1 is not null",)
    
    =TOCOL(SORT(A2:A,B2:B<>"",0),1)