Fabrice
Fabrice

Reputation: 535

Google sheets query & fix number of rows as result

I need to format a table with the result of a query. My table shall be 15 rows long. Sometimes my query returns less rows. Is there an easy way to initialize the remaining rows to 0 (or any other value or string)?

I tried to initialize all rows first but the query does not expand due to these init values.

Hope I'm clear (the purpose is then to display a chart and if values are not present my series are shifted)

Upvotes: 1

Views: 241

Answers (1)

kishkin
kishkin

Reputation: 5325

Try this:

=ARRAY_CONSTRAIN(
  {
    QUERY(data, "SELECT ... LIMIT 15", 0);
    SEQUENCE(15, 1, 0, 0)
  },
  15,
  1
)

Assuming you have only one column as the result of QUERY. If more, then set the 2nd parameter of SEQUENCE to that number.

Upvotes: 2

Related Questions