google-sheetsgoogle-sheets-formula

Add Column After Importrange


I have data and I want to combine it with IMPORTRANGE. For each IMPORTRANGE, I would like to add a column with specific data afterwards.

I have try this

=QUERY({
  IMPORTRANGE(Sheet1!C2; Sheet1!D2 & "!A3:Q");
  ARRAYFORMULA(IF(LEN(IMPORTRANGE(Sheet1!C2; Sheet1!D2 & "!A3:Q")); "Location1"; ""));

  importrange(Sheet1!C3;Sheet1!D3&"!A3:Q");
  ARRAYFORMULA(IF(LEN(IMPORTRANGE(Sheet1!C3; Sheet1!D3 & "!A3:Q")); "Location2"; ""))

};"SELECT * WHERE Col16 > 0 ")

"Location1" and "Location2" not show.

I want something like this

Column A-Q Column R
(from importrange Sheet1!C2) Location1
(from importrange Sheet1!C3) Location2

this is the example I make link


Solution

  • Here's one approach; the formula also automatically imports if any new Branch/URLs are added in Sheet1 tab

    =reduce(tocol(;1);Sheet1!B2:index(Sheet1!B:B;match(;0/(Sheet1!B:B<>"")));lambda(a;c;vstack(a;
       let(Σ;query(importrange(offset(c;;1);offset(c;;2)&"!A3:Q");"where Col16>0");{Σ\wrapcols(c;rows(Σ);c)}))))
    

    enter image description here