Google Sheets – How to Calculate Expression for Each Row in Range

google sheets

Assume I want to calculate the weighted value of "value 2" based on the total of "value" if an indicator = 'Y' , how to do this without adding an extra column?

So essentially I want to know how I can apply an expression for each row in a certain range ("artificial column") which I can then apply e.g. a SUM on.

In the screenshot below, how can I calculate the Red Formula without adding an extra column?

screen shot of sample data

Best Answer

=sum(arrayformula(A2:A4*C2:C4*(B2:B4="Y")))