Trying to return topmost row in a lookup [duplicate] - excel

This question already has answers here:
Return max index value in vlookup
(3 answers)
Closed 8 years ago.
I have a sheet that's full of prices, products, and locations. I currently have a MAX/IF formula that goes to this sheet, finds the product in col A, then returns the highest value from cols C:G. Now I need to have the next cell over display the location where that price originates.
Example:
A - B - C - D - E - F - G
1 - PRODS - ID - L1 - L2 - L3 - L4 - L5
2...
5 - Prod4 id1 $100 $125 $155 $110 $150
6...
Product: Prod4
Price: $155
Location: ???
So here I have a cell that says what product, then the price cell using MAX/IF statements gets to the highest price in col C:G after finding the product in col A. So how do I now return which location that price is in. The location box needs to have a formula to return (in this example) "L3" since it's the col that has the highest price. Row 1 is the headings so it will always have the value needed, but wont always been the same index from the price (because the row the price is in could change). I've tried making index/match work but can't seem to return an actual value when using it.
Edit:
This is a direct copy paste from my spreadsheet. Buy Averages is the name of the sheet where the products are listed. G15 is where the highest price is listed, F14 is where the name of the product is listed. I have several hundred products, but the likelihood of passing 1k isn't very high.
=INDEX('Buy Averages'!$C$1:$G$1,MATCH(G15,INDEX('Buy Averages'!$C$2:$G$1000,MATCH(F14,'Buy Averages'!$A$2:$A$1000,0),0),0))

You were on the right lines with Index and Match
first we need to find the max price - you already have that calculated, so I'll just use a placeholder of MAX(5:5)
Next, we need to find where that value is by using Match, which gives us MATCH(MAX(5:5),5:5,0), the zero because we require an exact match
Next we use that number in an index, with the first row as where we are searching, a row number of 1, and a column of the number we got from the Match:
=INDEX(1:1,1,MATCH(MAX(5:5),5:5,0))
if you are using a version of excel that is 2003 or before, you will have to replace the rows 1:1 with A1:GA1 (or however far the row runs), and the same for the other row references, changing only the row number
=INDEX(A1:GA1,1,MATCH(MAX(A5:GA5),A5:GA5,0))

Related

Formula in excel that does average to all cells that matches the number in a row, the former number and next number

I need to do a formula in excel that does average to column of votes if it matches to the season in that row, former, and next season (except from the first and last season). For example, if I am in a row on season 3, I need to do average of all the votes in seasons 2,3 and 4.
Right now I tried :
=AVERAGEIFS(I$2:I$237,B$2:B$237,$B2,B$2:B$237,IF($B2=1,$B2,$B2+1),B$2:B$237,IF($B2=10,$B2,$B2-1))
(I- is the column of votes, B - is the column of seasons)
But it returns error: #div/0!
This is a small example of the table.
I would like for help to solve this problem.
In Averageifs, the different conditions have an AND relationship - so at the moment you are asking for rows that match both previous season AND next season which is impossible. There aren't any, so you get the #DIV/0 error.
Try it with a range instead:
=AVERAGEIFS(I$2:I$10,B$2:B$10,">="&B2-1,B$2:B$10,"<="&B2+1)

Need help in excel formula

1) I have two tables. 1st table contains data for more then 20,000 rows and 2nd table I already have the following columns details i.e. Region, Item, Number and I just have to get the Total value of the product from the 1st table
2) There are two types of prices in the 1st table . One is Retail Price and Another one is a Wholesale price
3) In each of the regions Rep, Item and Numbers are same in most of the cases, but the Total price is different
4) I am able to get the Total price details in 2nd table through vlookup formula (After concatinating the following columns i.e. Region, Item and Number from both the tables) wherever there is an account number for retail price
5) Currently I am manually updating "Total Price" details in 2nd table for Wholesale price which is taking lot of time.
Is it possible to build a formula to get the wholesale price details in the 2nd table, since there are more then one account number, but the price is same
If the wholesale price is the lowest price for the specific item, then you can find it with the formulas MIN and IF.
Based on your screen shot:
D is the column with the list of items
I5 is the cell with the item name for which you want to find the wholesale price
F is the column with the list of prices
If you enter the following formula in cell K5, it should find the lowest price for pencils
=MIN(IF(D:D=I5,F:F))
On this link, there is an explanation if you want to use multiple criteria.
http://www.contextures.com/excelminmaxfunction.html
try the sumifs function.
It takes multiple arguments and criteria. So it should look something like:
cell value at j5 = sumifs(f3:f23, b3:b23, h5, d3:d23, i5....)
you need to mark off which rows in your first table are wholesale selling. So it should be a column of some kind. Once you do that, let's say in column G, then you add onto the sumifs function...
, g3:g23, L5)
What you're doing is summing up all of the values in column F where h5 (region) matches in b3:b23, i5 (item) match in d3:d23, and where L5 (retail type) match in a new column g2:g23.
This will find all of the values that match that criteria exactly.
Vlookup is useful, but it's harder to scale IMO than the advanced if functions.
SUMIFS is probably the better way to go on this one, but as an alternative there is also SUMPRODUCT.
=SUMPRODUCT(($H3=$B$3:$B$20004)*($I3=$D$3:$D$20004)*($J3=$E$3:$E$20004)*($F$3:$F$20004))
The * acts as an AND statement in a logical check, and each of the ($H3=$B$3:$B$20004) is a logical check. When the row is true it will evaluate to 1. When it is false it will evaluate to 0. in the end you wind up with a list of prices or 0s that get summed. The end result is the sum of everything that matches your criteria.
The danger of using this formula is that it can get labour intensive as it is performing array calculations without being an array formula.

COUNTIF Unique values

I used this formula to find SKU counts in certain categories given multiple criteria:
=+COUNTIFS(Data!$AG:$AG, ">"&0,Data!$AO:$AO, "="&$A115,Data!$L:$L, "="&D$104,Data!$P:$P,$B$103)
I am able to find the SKU counts but it gives me the total SKU count, I believe because it now counts any SKU with inventory greater than 0 with my multiple criteria.
How can I change the formula to get the unique SKU count per division?
Column AG: Inventory
Column AO: Division Name
Column L: Month
Column P: Year
Column T: SKU Code(written out) - what I need to find unique values of.
Example here: dropbox.com/s/hxbt7hb9l8hf4w6/Sample%20Example.xlsx?dl=0
If you created a helper column on the input sheet with the formula (e.g. in BG2):
=1/COUNTIFS(T:T,T2,AG:AG,">0",AO:AO,AO2,L:L,L2,P:P,P2)
This means that if you had, for example, 5 times the SKU in one Division/Month/Year, you would get 1/5. Then, in the calculation sheet, replace your COUNTIFS with a SUMIFS (summing your new helper column, using same conditions). This will mean that your 5 duplicates (with 1/5 in the helper) get summed to 1 - i.e. 1 unique SKU
EDIT
Because there are some where there is no positive inventory, the count gives you 0 and you get a #DIV/0! error... so we can fix that with:
=IFERROR(1/COUNTIFS(T:T,T2,AG:AG,">0",AO:AO,AO2,L:L,L2,P:P,P2),0)
Then, in the Output-EOM Unique SKU Count sheet, in cell e.g. B6, use:
=SUMIFS(input!$BG:$BG,input!$AO:$AO,$A6,input!$L:$L,B$5,input!$P:$P,$B$4)

Find a value that corresponds to another

I have set up a table that includes values for products used in several industries. I have used the COUNT function so I can find the industry that uses the greatest number of products.
Now I want to identify the cell in the column of COUNT results that has the maximum value and return the name of the corresponding industry from the left hand column.
Use MAX to identify the highest count amongst the counts and then use that to VLOOKUP the matching industry. For VLOOKUP to work the count must be left of the industry. If you can't arrange this, you can accomplish the same thing with a combination of INDEX and MATCH.
For example, if you have counts in A1:A6 and industries in B1:B6, you can find the industry with the most counts with
=VLOOKUP(MAX(A1:A6),A1:B6,2,false)
Use =MAX to find the maximum value, then =MATCH to find which row the maximum value is in and =INDEX to find the name of the corresponding industry. Since left hand column =VLOOKUP is unlikely to suit.
If you have the count value all figured out and you know what sheet that they are located within in your workbook, you can use something similar to the following:
Using the following data:
Col A Col B
Industry ProductVal
A 11
B 45
C 22
D 9
E 8
F 12
Assuming that you already have assigned 45, the largest value in column B to a cell, you can substitute the 45 below for that cell.
=INDEX(A2:B7,MATCH(45,B2:B7,0),1)
The above excel formula will return the value of B which is the value to the left of the "match value" of 45. A brief explanation is you define the index as the entire set of columns that are bounded on the left by the industry and on the right by the value. In the above example that was A and B. The Match then reads, find the value of 45 in the column B from row 2 - row 7 and match the first exact match (that is what the zero is for) and the 1 from the index function indicates that you will return the value that is in the first column (reading left to right) of the INDEX array A2:B7.
You can find an explanation of index here, an explanation of match here
and a nice explanation of using them together here.
Best of luck.

return the nearest number value above current cell within a list in Excel 2010

This is a little difficult to explain but I have a list of data, all in one column, that contains a department number and then below each department number is a long list of brands that correspond to that department number. So within this list there are multiple departments with brands listed underneath them.
My goal is to somehow return the value of the department next to each brand but because the department number is located above the list of brands and the data is changing each time I repull the report, the row numbers will not remain them same and there may be duplicate brand names, and I cannot figure out what formula to use because it is all contained in one column.
I need to come up with some type of formula that doesn't just search, but returns the value of the next number or value above the current cell and skips all of the text or blanks in between so it will grab the department number above it. Is there a way to do this or a better way to accomplish the goal of assigning each brand to the department above it while allowing for changing data each time I pull the report?
I tried replacing all of the text with 0's or blanks and then used the indirect function to say: =IF(BG24="",INDIRECT("BF" & ROW() - 1),""), but I assumed it would continue to loop and skip the zeroes or blanks until it found a number, but it did not, it just returned the zero value.
If I understand your problem correctly, the following formula should do it. Put it in cell B2. In cell A1, I'm assuming that there's the department number.
=IF(ISERROR(A1*1), IF(ISERROR(A2*1), B1, ""), A1)
This will work for a table like the following where no brands are numbers only:
1
Brand1
Brand2
2
Brand1
Brand2
To become:
1
Brand1 1
Brand2 1
2
Brand1 2
Brand2 2

Resources