Search code examples
sortinggoogle-sheetsgoogle-sheets-formulalimitgoogle-query-language

Copy/pasting query in Google Sheets between cells with automatic replacement of values


I have this query in my sheet: =query(A2:A100, "Order by A Desc Limit 20")

I want to copy and paste it to more cells and expect it will update range and column from A2:A100 to B2:B100, C2:C100 etc.. and A in query to B, C etc.

=query(B2:B100, "Order by B Desc Limit 20")

=query(C2:C100, "Order by C Desc Limit 20")

But when I copy/paste, it only updates range, but not query. How to implement it?


Solution

  • use:

    =SORTN(A2:A100; 20; 1; 1; 0)