SOLVED - Need help for a ARRAYFORMULA / MAP Query with transpose - auto grabbing google images


I’ve seen a few subjects on the forum on how to search a Google Image and put the link in a google sheet (in order to display it as an image in Glide).

I found this query :
=TRANSPOSE(INDEX(QUERY(IMPORTXML(““&B33&”&source=lnms&tbm=isch”; “//a//@src”);“where Col1 contains ‘image’ limit 2”)))

Where the “B33” is the element I want to search for on Google Images (can’t use Pexels because it’s mostly names of well known people).

My problem is to make it work in an arrayformula ; and from what I found it’s not possible, but it might with MAP.
I’ve come to this : =MAP(B:B;LAMBDA(n;{n\TRANSPOSE(QUERY(IMPORTXML(““&B:B&”&source=lnms&tbm=isch”; “//a//@src”);“where Col1 contains ‘image’ limit 2”))}))

It does auto-fill the whole column, but it does it only for the first value of my B column, doesn’t compute all the lines.

Hope I’m clear and this can also be usefull for other people,

Thanks a lot !

SOLVED : I definitely wasn’t far : “just” needed to understand the Lambda function and give it another night.
To anyone wanting to use this, the right way to do is to change B:B in the query / importXML function to give it the first parameter given by MAP, which will be B1:B (or B:B) ‘inside’ of ‘n’. Just use this and you’ll be good :

=MAP(B:B;LAMBDA(n;{n\TRANSPOSE(QUERY(IMPORTXML(““&n&”&source=lnms&tbm=isch”; “//a//@src”);“where Col1 contains ‘image’ limit 2”))}))

1 Like

If you don’t have a huge amount of items, Serp API might be what you need.


Beautiful stuff !
I needed a solution without API thought, and to auto-complete columns.

Anyway, as I wrote : I solved it :slight_smile:

Is there a reason you don’t use Serp with Glide Tables in exchange for Google Sheets?

My clients need the Google Sheets for modifying some stuff in it and making saves in Sheets, it’s one of their reasons for choosing Glide :slight_smile:

1 Like