A B
France 152
Italy 255
France 221
Spain 215
USA 222
Spain 155
I desire to add each value occurring in front of repeating countries using Vlookup function
Solution:
A B
France 373
Spain 370
If you use a SUMIF then you can total the columns
If the data starts in cell A1 then in cell C2 type
=SUMIF(A:A,A3,B:B)
then drag the formula down. this will give totals for each country
Or if you just want to show the first instance (where it says France for example) then use
=IF(COUNTIF(A$1:A2,A2)=1,SUMIF(A:A,A2,B:B),"")
You won't be able to do it with a vlookup.
You could use a pivot table which might be easier and that is useful for this exact type of question.
To get the list of repeating countries enter the following formula in Cell D2
=IFERROR(INDEX($A$2:$A$7,MATCH(1,INDEX((COUNTIF($D$1:D1,$A$2:$A$7)=0)*(COUNTIF($A$2:$A$7,$A$2:$A$7)>1),0,0),0)),"")
Then to get sum of corresponding country, in Cell E2 enter
=SUMIF($A$2:$A$7,D2,$B$2:$B$7)
Drag/Copy formulas as required. See image for reference.
Related
This is a kind of an extension to this problem: Excel - Sum values from the data set based on criteria
I have a table like this:
Country Region Code Name of product Year Value
Sweden Stockholm 52 Apple 1995 1000
Sweden Malmö 25 Pancake 1991 1500
Sweden Malmö 52 Apple 1992 2470
Finland Helsinki 21 Candy 1987 2500
Denmark Copenhagen 52 Apple 1987 2571
What I want to do is to make a code that can give me the sum of the nth largest value of products that have been sold in a specific country.
That is, if I want to get the highest value for products sold in Sweden it should return Apple and the sum of sold apples, 3470.
edit: The solution of Glitch_Doctor:
Firstly, for the value:
Both formulas are array formulas, please confirm the formula with Ctrl+Shift+Enter while still in the formula bar
=MAX(SUMIFS($F$2:$F$6,$A$2:$A$6,$I2,$D$2:$D$6,$D$2:$D$6))
This builds an array of SUMIFS() results for the country in cell $I2 and each product name then grabs the MAX() result.
And the product name:
=INDEX($D$2:$D$6,SMALL(IF(SUMIFS($F$2:$F$6,$A$2:$A$6,$I2,$D$2:$D$6,$D$2:$D$6)=$K2,ROW($D$2:$D$6)-1),1))
Now using the max SUMIFS() result, we reference the list of SUMIFS() results and get the row of the product (offset to the start of the INDEX()) and retrieve the smallest row number.
You can adjust MAX() in the first formula to be LARGE(,n) where n is the nth largest result.
My Excel table is looking like this.
A column is the one that I want to fill in with correct data.
B column is where the lookup values are.
C column is the one where I want to extract data from.
D column is where data from B column will be searched.
For example, if data from B2 is found on D7 cell, I want to have in A2 the value from C7.
My Countries///My Codes////All Countries//////All Codes
AD Afghanistan AF
AU Albania AL
Algeria DZ
American Samoa AS
Andorra AD
Angola AO
Anguilla AI
Antarctica AQ
Antigua and Barbuda AG
Argentina AR
Armenia AM
Aruba AW
Australia AU
Austria AT
Azerbaijan AZ
It would be much appreciated your help because I would like to learn as much as I can about excel formulas.
Kind Regards,
Ioan
In A1 enter:
=INDEX(C$1:C$15,MATCH(B1,D$1:D$15,0))
and copy down:
Note:
MATCH() finds the row.INDEX() grabs the value.
Chris is right, looks like you need a vlookup, example
B1 would be
=Vlookup(A1,c1:d200,2,0)
B2 would be
=Vlookup(A2,c1:d200,2,0)
And so on
It works like this
Vlookup (value to lookup, range the lookup and return values are in, column number from range you want to return, exact match only (0 or false))
Though Chris's link is more detailed
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.
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
I have an Excel sheet that has values repeating in different rows of the same column (Obtain Marks). In RANKS column I want a grade assigned.
My problem is assigning the same rank to cells having the same Obtain Marks values.
How do I assign the same rank to the same Obtained Marks using an Excel formula?
Obtain Marks RANKS
212 1
212 1
212 1
211 2
210 3
209 4
209 4
Assuming Obtain Marks is in A1 and is sorted in order, if you want grouped by rank then I suggest in B2 and copied down to suit:
=RANK(A2,A$2:A$7,)
If you post includes under RANK the desired output then I suggest instead 1 in B2 and in B3 and copied down to suit:
=IF(A2=A3,B2,B2+1)
Either way each group should have a distinct value.
You can derive a pseudo-RANK.UNIQUE formula by modifying an old standard method of a SUMPRODUCT-style COUNT.UNIQUE formula.
The formula in B2 is,
=SUMPRODUCT((A$2:A$8>=A2)/COUNTIF(A$2:A$8, A$2:A$8&""))
Fill down as necessary.