 # How to categorize companies in Excel

Dear All,

First off; thank you for taking the time to help me.

I've been looking for the right fix for my problem but can't wrap my head around it.

Solution: formula which categorizes companies, in category A, B or both, based on money spent.

Situation:

I've got three excel files. Excel file 1 contains companies of which i want to know whether they belong to Category A, Category B or both. The only way for me to know whether the company named in excel 1 belongs to one of the categories is to look up the name or number in Excel 2 & 3 and check whether money was spent on them. If excel 2 states a positive amount then the company belongs to category A, if excel 3 states a positive amount then the company belongs to category B. However, if excel 2 & 3 state a positive amount then the company belongs to category A & B.

• I've used the IF function and Vlookup function

Vlookup

1. Look up the company name of excel 1 in excel 2

2. If found name the amount spent

IF function

1. If the amount is >=0.01

2. If true then return "category A"

3. If False then return "no spend or Negative"

I have done the same for category B but repalced excel 2 for excel 3.

Problems encountered:

I have encountered the following problems

• Because of wrongly spelled names or case sensitivity some suppliers are not found and excel returns #N/A
• Excel 2 and 3 might contains multiple dates on which money has been spent. With Vlookup the first money spent is found and returned. So if the first money spent is -20, excel will return "No Spend or Negative". However, the other dates have spent which are positive (e.g. +40 or +50). Because Vlookup directly takes the first found value and doesn't look further, a company can be categorised incorrectly.
• If the company is not found in excel 2 or 3, the function returns #N/A.
• some companies have nagetive money spent but in total it is positive. For example; first time money spent on a company is -20, the second time it is 40 and the third time it is 10. The total is still positive because -20 + 40 +10 = 30 spent.

Actions taken:

I have tried the following solutions.

• To prevent wrongly spelled names, I have replaced the name with supplier number. Shortly said; supplier number will be looked up in excel 2 and 3 instead of name. However, i still receive the same output.

Excel Files and the containing data

Excel 1 contains

1. Approved companies
2. Company name
3. Company number
4. Bunch of other irrelevant data

Excel 2 contains

1. Money spent on companies which belong to category A
2. Company name
3. Company number
4. Amount of money spent
5. Currency
6. bunch of other irrelevant data

Excel 3 contains

1. Money spent on companies which belong to category B
2. Company name
3. Company number
4. Amount of money spent
5. Currency
6. bunch of other irrelevant data

Again thank you for helping me.

6 Replies

# Re: How to categorize companies in Excel

That's more job for Power Query. If with formulas when use SUMIFS(), not lookup functions.

# Re: How to categorize companies in Excel

I did not understand/comprehend what you just said. I dont use power query. I want to use excel.

# Re: How to categorize companies in Excel

Power Query is part of Excel, this functionality is under Get & Transform tab.

Again, you may use SUMIFS() formulas to return companies spending.

# Re: How to categorize companies in Excel

Power Query as well as Visual Basic macro language are both parts of an Excel installation but they demand knowledge very different from the spreadsheet.

Using SUMIFS to find the total amount spent for each company mentioned in table Excel_1 will calculate the sum no matter their order respective tables.

If the amount is greater than zero, the IF statement should result in a letter, A or B.

The two are then concatenated using &.

``````=IF(SUMIFS(Excel_2[4. Amount of money spent];Excel_2[3. Company number ];[@[Company number]])=0;"";"A")
&
IF(SUMIFS(Excel_3[4. Amount of money spent];Excel_3[3. Company number ];[@[Company number]])=0;"";"B")``````

Excel_1 columns E to I calculates this step by step while col J makes it all in one formula. If you are not using 'pyamas' tables, change the column references to your columns, eg cell J3 using ranges in other files like

``````=IF(SUMIFS([Book2]Sheet1!\$D:\$D;[Book2]Sheet1!\$C:\$C;C3)=0;"";"A")
&
IF(SUMIFS([Book3]Sheet1!\$D:\$D;[Book3]Sheet1!\$C:\$C;C3)=0;"";"B")``````

# Re: How to categorize companies in Excel

Oh thank you. I did not know that.

# Re: How to categorize companies in Excel

I will read your entire comment and try to apply it. Thank you for your time and of course the pictures you have provided. I appreciate the effort you took to replicate in excel that which i mentioned.