Home » excel » Excel formula to find similar values in a column and return value based on output

# Excel formula to find similar values in a column and return value based on output

Questions:

I have an excel sheet which lists all the products that I have for sale. These products are grouped into separate categories. If any one product in a category is out of inventory, I want to classify all products in that category as out of inventory.

Can I do this in an if statement? I need to add multiple other if conditions to this formula. If I can’t do it in an if statement, how can I do this?

I’ve tried googling it but i’m sure i’m not searching for the right thing as i’m not getting any solution.

As a simplified example, I’ve listed the categories and the inventory of products in them. If the inventory of any product in a category is 0, the output should be “No Inventory” else the output should be “Inventory”. You can see that the inventory of item 4 which belongs to category A is zero, therefore the output for all items in category A should be “No Inventory”

``````Categories  Inventory   Output
A           2324      No Inventory
A           66        No Inventory
A           9129      No Inventory
A           0         No Inventory
B           1453         Inventory
B           967          Inventory
B           5109         Inventory
B           75           Inventory
B           1069         Inventory
``````

I’d appreciate your help in making this work!

the inventory of item 4 which belongs to category A is zero, therefore the output for all items in category A should be “No Inventory”

So if the stock of any item in a category is 0, then all items from that category should be marked as No Inventory?

In that case, you can use the formula COUNTIFS combined with an IF. With COUNTIFS you can count how many rows of a specific category and inventory 0 you got. If that count is 1 or more, then with an IF return No Inventory. If not, return Inventory.

The formula I’ve used in column C is:

``````=IF(COUNTIFS(\$A\$2:\$A\$10;A2;\$B\$2:\$B\$10;0)>0;"No inventory";"Inventory")
``````

``````=IF(COUNTIFS(\$A\$2:\$A\$10;A2;\$B\$2:\$B\$10;0)>0;IF(B2=0;"Pause this";"No inventory");"Inventory")