Search code examples
google-apps-scriptgoogle-sheetsgoogle-sheets-formulagoogle-sheets-query

How to query an array in Google Sheets?


In Google Sheets i have in a cell an array like [27, https://www.example.com/page1.html, false, false, 1]

How can i access its single parts with a formula?

I know a way through =SPLIT(), like =split(split(A2,"["),",") - but i would very like, if its possible, to access each part directly (each array has always the same amount of parts in my data set).

Maybe something like =QUERY(query(A2,",",1)) - cell, divider, item number...? - Result is 27.


Solution

  • =INDEX(SPLIT(A2,"[,]"),1)
    
    • SPLIT by each of these characters [,]
    • INDEX into the resulting array