简体   繁体   中英

Reference a cell using IF inside VLOOKUP on Google Sheets

I want to perform a vlookup with an if statement inside. I currently have

=LOOKUP("Metallic Gold Flash Tattoo Arabic",A:A,IF(INDIRECT(ADDRESS(ROW(), E)))<0,INDIRECT(ADDRESS(ROW(), C)),0)

I want to sum up all the units of that product type in column A, however I only want to sum up the ones that have been sold and not bought. Column C is units and E is price. Sold are positive and negative are bought.

I am using Google Sheets.

I'm assuming you want to sum column C (quantity of units) when the description matches in column A and col E is > 0

Try using SUMIFS - that should work in both excel and google sheets, ie

=SUMIFS(C:C,A:A,"Metallic Gold Flash Tattoo Arabic",E:E,">0")

....or do you want to get the total cost price of those units (Col C multiplied by E for the relevant rows)?

For that you can use this formula in google sheets

=sum(filter(C:C*E:E,E:E>0,A:A="Metallic Gold Flash Tattoo Arabic"))

You could try a query:

=QUERY(A:E, "SELECT A, SUM(E) WHERE A = 'Metallic Gold Flash Tattoo Arabic' AND C > 0", 1)

I'm assuming that column C contains the positive and negative values indicating sold and bought.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM