Reputation: 19
I hope you are great. Well I am creating a Google Sheets "database" for one client, and what I want it to do is this:
I already created a data validation column (the Product_Sold cell), where the client can select (in a list of items) the type of product that he sold (like a chocolate cake or a vanilla cake), and in the next cell, I want the excel to write the price of that item automatically, for example, if he selects in the Product_Sold cell a "Chocolate cake" I want Google Sheets to automatically write in the Product_Price cell the price of the "Chocolate cake", so the client only has to keep the prices up to date and select the product name and quantity that the client bought, therefore saving time and keeping it simple to him, and making sure that he has fewer opportunities to make mistakes!
How could I do that? I mean, I tried using IF functions and it worked, but with only 1 item, how can I do it with more than 1 item, like with 20?!
This is what I did:
=IF(Product_Sold = "Chocolate cake", 14,0)
Here "14" is the price of the chocolate cake. The question is like I said before, how can I do that, but with 20 products or more? I know how to do it in Python, but not in Google Sheets, LOL. Please help me!
Upvotes: 0
Views: 1237
Reputation: 1
you can nest IF statements and hardcode all prices:
=IF(A1="vanilla", 10,
IF(A1="chocolate", 20,
IF(A1="......", 30, )))
or you can create a "table of contest" and refer to it with VLOOKUP like:
=IFNA(VLOOKUP(A1, C2:D, 2, 0))
where C2:D holds names in C column and prices in D column, so when vlookup detects match it will bring up the correct price
Upvotes: 1