Search code examples
jsongoogle-apps-scriptgoogle-sheetsgoogle-sheets-formulacustom-function

Using cell adjacent to ImportJSON throws error: Array result was not expanded because it would overwrite data


I am importing an individual parameter using the importJSON function in Google Sheets.

See post: Importjson exclude parameters spreadsheet

When I use

=importJSON("url", "/name","noHeaders") 

this works perfectly to import the exact cell I need but I cannot use the cell to the right of the import.

E.G:

Cell A1 =importJSON("url", "/name","noHeaders"), If I type any text into Cell B1 I receive

"Error: Array result was not expanded because it would overwrite data in B1"

and Cell A1 displays #REF!. Then once I delete text in B1 the importJSON value reappears back into A1 and the error clears. Is there a way to fix this so I can have data next to the importJSON cell?

Any help would be much appreciated.


Solution

  • If you only want 1 value from the import, INDEX into it:

    =INDEX(IMPORTJSON("url", "/name","noHeaders"), 1, 1)
    

    You may also use ARRAYCONSTRAIN() to constrain the array.

    Syntax:

    =INDEX(array, [row], [column])