1

I am trying to multiply the number of owned shares by the current price, however, I am getting the following error:

Function MULTIPLY parameter 2 expects number values. But 'OWNED SHARES' is a text and cannot be coerced to a number.

enter image description here

SYMBOL OWNED SHARES SHARES PRICE
ABML 100 0,5
BABA 100 100

Function is

={"SHARES PRICE";BYROW(A2:A, LAMBDA(r, IF(r="",,GOOGLEFINANCE(r, "price")*B:B)))}

I tried *B2:B but it does not work.

Excel demo: https://docs.google.com/spreadsheets/d/1e9khzIuRrx9kJHyp8CqS22qX98aLg-50cfd9FCks7fc/edit?usp=sharing

Note: I added +100 into the Owned Shares Function just for the demo it loads the data from another sheet in reality.

vohratom
  • 422
  • 7
  • 16

2 Answers2

3

I created a working formula in your table link

The problem is that by multiplying by B:B you multiply the text Owned Shares. Here what you'll want to do is to get the values in your Owned Shares after the 1st line which will cause an error for every line.

What you need to do is use this :

={
"SHARES PRICE";
BYROW(
    F2:F, 
    LAMBDA(
        r, 
        IF(
            r="",
            ,
            IF(
                ROW(r)=1,
                ,
                GOOGLEFINANCE(
                    r, 
                    "price"
                )
                *INDIRECT(
                    CONCAT(
                        "B",
                        ROW(r)
                    )
                )
            )
        )
    )
)}

Here I replaced our *B:B by An Ifchecking if it's the first line. If not, It get the cell value in B and at the row of r with Indirect and multiply it by your Owned Shares values.

Neo
  • 525
  • 3
  • 17
2

use:

={"SHARES PRICE"; INDEX(IFERROR(BYROW(A2:INDEX(A:A, COUNTA(A:A)), 
 LAMBDA(x, GOOGLEFINANCE(x, "price")))*B2:B))}

enter image description here

player0
  • 124,011
  • 12
  • 67
  • 124