google-sheetsgoogle-sheets-formulagoogle-finance

How to use LAMBDA with GOOGLEFINANCE to perform currency conversions in an array?


I'm trying to write a formula that checks the currency of a stock position and performs a currency conversion if it is anything other than USD. I'd like to make column F into an array but the GOOGLEFINANCE formula doesn't work with the arrayformula. So I've tried using LAMBDA functions with BYROW and MAP but without success.

Yellow cells contain formula. Blue cells are manually inputted data.

I appreciate anyone who can take a look at my spreadsheet (linked below) and see what's the best solution for this. Sheet 2 is editable.

https://docs.google.com/spreadsheets/d/1JWkgH2Nf7CFI0Nh9H2-qEMRcwd8iMz7nxebuauplFiE/edit#gid=1126538379

Thanks! J

screenshot


Solution

  • added formula to your sheet:

    =MAP(C2:C,E2:E,LAMBDA(cx,dx,IF(cx="",,ROUND(IFS(cx="GBX",(GOOGLEFINANCE("GBPUSD")*dx)/100,cx="USD",dx,LEN(cx),GOOGLEFINANCE(cx&"USD")*dx),2))))

    -

    enter image description here