Google-sheets – Want to use a cell to get a limit number

formulasgoogle sheetsgoogle-sheets-query

Here is my query. I want "select * limit 5") the 5 to come from a cell. How do I do that?

=ArrayFormula(AVERAGE(QUERY(SORT(Tabell!D4:D33,ROW(Tabell!D4:D33)*ISNUMBER(Tabell!D4:D33),0),"select * limit 5")))

Best Answer

Use the following, assuming the limit is on cell A1

=QUERY(SORT(Tabell!D4:D33,ROW(Tabell!D4:D33)*ISNUMBER(Tabell!D4:D33),0),"select * limit " & A1)))