Count the number of companies per country in Excel - excel

I have the following 2 excel sheets in the same workbook:
companies:
A B
1 COMPANY COUNTRY
2 Apple USA
3 Microsoft USA
4 Samsung Taiwan
5 Philips Netherlands
6 Tulip Netherlands
countries:
A B
1 COUNTRY NUM_COMP
2 USA 2*
3 Taiwan 1*
4 Netherlands 2*
In sheet countries column B I need the number of companies per country. I have now counted them by hand, but I need a formula for cells B2 to B4 to do this automagically, since the actual sheet is much, much longer than this example.
Can anyone help me? Your help is greatly appreciated.

Function 'Countif' should be helpfull :)
=COUNTIF(B:B;B2)
cheers
Sky

For the number of different companies per country try this formula in B2
=SUM(IF(FREQUENCY(IF(companies!B$2:B$2265=A2,MATCH(companies!A$2:A$2265,companies!A$2:A$2265,0)),ROW(companies!A$2:A$2265)-ROW(companies!A$2)+1),1))
That's an "array formula" which needs to be confirmed with CTRL+SHIFT+ENTER so that curly braces like { and } appear around the formula in the formula bar.
Now copy formula down column

Related

Search text in different cells and add all results in a cell using Excel

Let's say I have this list:
Colorado US
Texas US
London UK
Berlin GE
Munich GE
I would like to obtain as result all the cities that end with "US" in a cell, just like this
Colorado US Texas US
I have applied the formula:
=IF(ISNUMBER(SEARCH(find_text;within_text));"Cell_of_CityName";"")
This works perfect if I do it cell by cell.
Is there a way to apply this formula to the whole column so that I dont have to do it always cell by cell?
Thank you in advance!
in B1:
=TEXTJOIN(" ",TRUE,IF(RIGHT(A1:A5,2)="US",A1:A5,""))

How can I automate these formulas?

Hello,
I need to automate these formula.
Wheat 2 USA minus wheat 1 USA, Wheat 2 Brazil minus wheat 1 Brazil, Wheat 2 Canada minus wheat 1 Canada, Wheat 2 Argentina minus wheat 1 Argentina and so on for every product and taking into account corresponding regions and week numbers.
Barley 2 USA minus barley 1 USA, Barley 2 Brazil minus barley 1 Brazil, Barley 2 Canada minus barley 1 Canada ...
A formula should work in such a way that when I populate it, it understands the logic and make a calculation.
Use LOOKUP to find previous value of current product:
=IFERROR(C2-LOOKUP(2,1/($A$1:A1=A2),$C$1:C1),"")
or so if the Input number column matters:
=IFERROR(C2-LOOKUP(2,1/(($A$1:A1=A2)*($B$1:B1=(B2-1))),$C$1:C1),"")
First: I like #basic's solution much better! I keep forgetting that =LOOKUP(LargerThanAll,Nums,Values) returns the value for the highest num!
That said, here's another way:
First, put your cursor on the top line and Insert - Table, making sure you check the "My table has headers" checkbox in the dialog box that appears.
Now, in addition to having it formatted, there are formula benefits.
Keeping with your example where the B2 = "Product",
Change F2 to "Product|Number" to create a new column
Change F3 to =[#Product]&"|"&[#[Input Number]] (Because you're using tables, you can use column names rather than cell references, [#ColumnName] is the column value for the current row, it will use that formula for the entire column, and the formula is stored once instead of once per row!)
Change G2 to "PrevRow"
Change G3 to =MATCH([#Product]&"|"&([#[Input Number]]-1),[Product|Number],0) (you now have the table row number for the previous value
Change E3 to =IF(ISNUMBER([#PrevRow]),[#Quantity]-INDEX([Quantity],[#PrevRow]),"")
Hide columns F and G. (Or fold their functionality into your Volume's formula so your volume formula doesn't need them and delete them.)

Vlookup from another sheet using multiple columns

I have an excel workbook with 2 sheets.
Sheet 4 and Sheet 5:
Sheet 4 has the following columns:
type model name year
U acura jane 1998
D honda peter 2002
U bmz fred 1993
Sheet 5 also has the same columns but with an additional column sales.
type model name sales
U acura jane 2.3
D honda peter 3.8
U bmz fred 19
IN both the sheets, I created an additional column called "key" concatenating type-model-name (A2&B2&C2)
type model name year key
U acura jane 1998 Dacurajane
D honda peter 2002 Dhondapeter
U bmz fred 1993 Dbmzfred
To get the sales in Sheet1, I am giving the following vlookup.
=VLOOKUP(E2|Sheet5!A2:F4|5|FALSE)
I looked at other similar answers, trimmed the columns and did what the recommendations were, but it still returns #N/A
Can anyone point out what my mistake it?
Thanks In advance.
Use INDEX/MATCH
=INDEX(Sheet5!D:D, MATCH(E2, Sheet5!A:A&Sheet5!B:B&Sheet5!C:C, 0))
Enter with Ctrl-Shift-Enter
Also I am assuming that the sales is in column D of Sheet5. If different, put the appropriate column in as first parameter to the INDEX function.
Also please consider using restricted range references in the match function, instead of full column references - for speed & efficiency.
on cell E1 you will have KEY on cell E2 you will place =CONCATENATE(A2,B2,C2,D2) Combines contents above into a phrase "DFocusManuel2016". That should work for the combine part just paste that and drag down as desired on E2.
You can cover the rest of the cell population by simply assigning links to the cells so on cell A2,B2,C2 and D1 you will have =SHEETNAME!Y10 which Y10 corresponds to the source cell and Sheet name to the source sheet.

Excel Index Partial match

I have Sheet1 with column A listing every single country in alphabetical order..
A
1 Afghanistan<
2 Albania
3 Algeria
4 American Samoa
5 Andorra
----------
228 United Kingdom
229 United States
etc
I have Sheet2 column A with empty cells with adjacent cells in column B listing address details
A B
1 empty cell Unit 3, Road;London, United Kingdom
2 empty cell Building 1, Road, TX, United States
3 empty cell 8th floor, Business Park, India 1234
etc
What I would like to know is how can I obtain the country within the address details in sheet2 column B and place them in Sheet2 column A, based on a match on the list of countries in Sheet1 column A.
Part of the problem is there is no coherent method as to how to country is placed within the address; could be at the end or in the middle of the address.
I have tried various index match formulas with no luck
any help would be appreciated.
I tried it with the reference table being in A1:B7, and lookups being A10:B10 onwards down. The formula is for these cells. You can adjust it for Sheet1/2!.
Assuming your data is in B10 onwards, and your reference data was in B1:B7, you can write this formula in A10 =INDEX($B$1:$B$7,MAX(IF(ISERROR(FIND($B$1:$B$7,B10)),-1,1)*(ROW($B$1:$B$7)-ROW($B$1)+1))). This is an array formula, so please hit Ctrl+Shift+Enter for excel to read it as an array formula.
(In the screenshot, I have pasted the table in A10:B12 as values only in D10:E12)
Text to Columns with a comma delimiter

Excel Sum If based on month of date range?

I have sheet with a list of users and their holidays taken like so:
Katie 1 01/01/2016
Dave 2 12/02/2016
Dave 2 12/12/2015
Katie 1 17/11/20165
Liam 1 05/01/2016
Marie 1 09/08/2015
Marie 5 23/09/2015
I am then using the following SUMIF formula on my other sheet to return the total number of holidays taken for each person
=SUMIF(Data!A$1:A$1000,A13,Data!B$1:B$1000)
This gives me a result like so:
Katie 2
Dave 4
Liam 1
Marie 6
However, now I want to turn my SUMIF into a SUMIFS which only returns the values for the month of January like so:
Katie 1
Liam 1
I know I can get the month of the date by using =TEXT('Cell Ref',"mmmm") but I'm not sure how I would combine this into an SUMIFS statement.
Can someone please show me how I can do this?
Thanks in advance
You would need to use an Array Formula:
=SUM(IF((Data!A$1:A$1000=A13)*(Month(Data!C$1:C$1000) = 1),Data!B$1:B$1000))
Since it is an Array formula it needs to be confirmed with Ctrl-Shift-Enter when leaving edit mode. Then copied down.

Resources