Search code examples
arraysgoogle-sheetsgoogle-sheets-formulaarray-formulasgs-vlookup

Google Sheets - Perform VLOOKUP on every row in column and return sum


I have a spreadsheet where I have a column with some products in them. Each product has a price listed next to it. I have another sheet with sales, and a column has the product sold in the sale. I want a formula that produces the total price of every sale made, and products can be repeated.

Basically, if I have two products, A and B, with prices $1 and $2, then I have 3 sales, two of the sales use product A and one uses product B, the formula should return $4.

I tried using an ARRAYFORMULA with VLOOKUP and LOOKUP but no luck. Any help is appreciated, thanks.

Edit: Here is an example sheet as requested. Feel free to edit it. https://docs.google.com/spreadsheets/d/1obHa6lbxJl_tJlQ811kjJralb7GCGjHtYBkOEPCzxAk/edit?usp=sharing


Solution

  • use:

    =ARRAYFORMULA(SUM(IFNA(VLOOKUP(Sales!C2:C, Products!A:B, 2, 0))))
    

    0