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

Posted by: admin May 14, 2020 Leave a comment

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!

How to&Answers:

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.

I copied your dataset: 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")
``````

Hope you can adapt this to your needs.

UPDATE 2: OP wants to classify all items in category A which are not zero as “Pause this”

Not sure if I understand this properly, but I guess that you want to check if the item inventory is 0. If true, then that specific item should return Pause this. If not, then return No Inventory. And of course, if none of the items of a specific category got stock 0, then it should return Inventory.

That’s what I have understood of your comment. You can adapt the previous formula like this, using a second IF.

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

I get this using this formula: Hope you can adapt it to your needs.