google-sheetsgoogle-sheets-formulaarray-formulasgoogle-finance

ARRAYFORMULA with GOOGLEFINANCE function


I want to create a simple function that returns company name for every line that is filled with the Symbol via GoogleFinance function, however, I am not able to make the script work for every line.

Here is the example:

https://docs.google.com/spreadsheets/d/1cJDq0smLUmbylAnAep3WIz41GvqH_dhpnLjnLEpOmAQ/edit?usp=sharing

CODE 1:

// DOES NOT WORK    
=ARRAYFORMULA(IFS(ROW(B:B)=1,"NAME",A:A="","",TRUE,VLOOKUP(GOOGLEFINANCE(A:A, "name"),GOOGLEFINANCE(A:A, "name"),1,0)))

Once I change the A:A to A2 it loads the data correctly, but I did not find a way of repeating the function for each row

I tried a workaround:

// DOES NOT WORK
=ARRAYFORMULA(IFS(ROW(B:B)=1;"NAME";A:A="";"";TRUE;VLOOKUP(GOOGLEFINANCE(CONCATENATE("A";row()); "name");GOOGLEFINANCE(CONCATENATE("A";row()); "name");1;0)))

But the same result..

Any ideas how to make it work?

Thank you in advance!


Solution

  • Use this

    =BYROW(A2:A, LAMBDA(r, IF(r="",,GOOGLEFINANCE(r, "name"))))
    

    enter image description here

    Or this with the header

    ={"Name";BYROW(A2:A, LAMBDA(r, IF(r="",,GOOGLEFINANCE(r, "name"))))}
    

    enter image description here