If truly empty columns are needed then it is necessary to insert null values rather than spaces into those blank columns. This could be very important when creating data for a CSV file to import other systems, for example.
Instead of querying the data cells directly, curly brackets can be used to build a data set from the cells and then query on that. Let's build it up in steps.
You have two ranges that you want to insert three blank columns between. Those ranges can be written like this.
={Sheet!A7:A, Sheet!B7:C}
You can't just insert ""
between those ranges because that would only be one row of data and the number of rows must match the number of rows in your source data.
A little trick with the LEFT
function can be used to make a blank cell for each row. The LEFT
function can take 0 for the number of characters to return, which will return an empty string no matter what data it is given. Any range from the source data can be used. I'll use A7:A
. When the whole thing is wrapped in ARRAYFORMULA
it will be evaluated for every row. That can be repeated for each blank column needed. The data set with three empty columns looks like this.
=ARRAYFORMULA({Sheet!A7:A, LEFT(Sheet!A7:A, 0), LEFT(Sheet!A7:A, 0), LEFT(Sheet!A7:A, 0), Sheet!B7:C})
There are some ways this could be shortened. One way is to make another data set inside a single LEFT
function. The function can deal with arrays and will return multiple columns of empty strings. This is only a little bit shorter.
=ARRAYFORMULA({Sheet!A7:A, LEFT({Sheet!A7:A, Sheet!A7:A, Sheet!A7:A}, 0), Sheet!B7:C})
If a large number of blank columns are needed then adding some character to each cell of the range, repeating it, then splitting it into columns on that character could be shorter. Changing the number of blank columns is as simple as changing the number of repeats. It does depend on choosing a character that would not be in the data, though, or it will break. Here's an an example with nine blank columns, which is no longer than with fewer blank columns.
=ARRAYFORMULA({Sheet!A7:A, LEFT(SPLIT(REPT(Sheet!A7:A&"~",9),"~"), 0), Sheet!B7:C})
Since there are three columns of source data and three blank columns are needed, it can be shortened the most by referencing a larger range in the source. Empty strings will still be output for each column. Although this version is much shorter it depends on having source data with enough columns.
=ARRAYFORMULA({Sheet!A7:A, LEFT(Sheet!A7:C, 0), Sheet!B7:C})
Now query that data set. Instead of referencing data by cell references, they are referenced in order as Col1
, Col2
, etc. Here's the whole thing together using the shortest version of referencing the data.
=QUERY(ARRAYFORMULA({Sheet!A7:A, LEFT(Sheet!A7:C, 0), Sheet!B7:C}), "Select * where Col1='Order'", 0)