Excel INDEX MATCH IF greater than 10% - excel

I'm trying to find the most efficient way to summarise an excel sheet where only the results that are higher than 10% are included in a separate sheet.
I know how to use INDEX MATCH, and need to go one further and only INDEX MATCH when VALUE is greater than 10%'
See table, where top sheet is found in other tabs and summary sheet will populate only the description where greater than 10%.
I'm sure there is an elegant way of doing this, and I seem to over complicate my steps, breaking them down into extra columns for if, then trying to match, then return the referenced value, but ultimately I fail.
Why can't I just use Index Match (0.1,C:C,-1)? Where 0.1 is 10%. Col E, unformatted 'real' value is 0.01-0.15. Excel fails if I try =Match(0.1,E:E,-1).

This is a common mistake with MATCH. To use greater than your data set must be arranged in descending order. Likewise with less than your data set must be arranged in ascending order.
I'd suggest using the something like the following formula instead
=INDEX(A:A, AGGREGATE(15,6,ROW($A$3:$A$5)/($D$3:$D$5>0.1),ROW(1:1)))
which returns

Related

Find closest value in a Poisson distribution table

I am trying to find the closest value in this Poisson Distribution table to help create some variation in my NHL game simulator. Right now I have the minimum value set to =(MAX(H4:R14)/1.25) and the max as MAX(H4:R14). My rand (random) value is set to =RAND()*($V$4-$U$4)+$U$4. My question is, is how do you find the closest value in the table when compared to the random value? Returning the closest match (percentage) is ideal and the table's values will change whenever the teams change. Eventually, I am trying to return the respective column and row values (goals for each team), but this is step 1 and haven't been able to figure it out yet - even with index and match. Feel like it should be fairly straightforward...
You may benefit from SUMPRODUCT and array formula to get closes match and goals values in rows and section. Just as example:
The upper table would be your data. The bottom table is just to check it it works, you can delete. This bottom table is just an absolute value of cell minus your rand. The minimun one is highlighted in green and that's the closest match. Notice how the formulas get the position of that match and the goals values:
Formula to get ROW VALUE:
=SUMPRODUCT(--(ABS(H4:R14-U6)=MIN(ABS(H4:R14-U6)))*G4:G14)
Formula to get COLUMN VALUE:
=SUMPRODUCT(--(ABS(H4:R14-U6)=MIN(ABS(H4:R14-U6)))*H3:R3)
Both of this formulas are array formulas, so to introduce them yo must press CTRL+ENTER+SHIFT or they won't work!
To get the closest match is just INDEX classic formula (we add +1 due to goals indexed as 0,1,2...):
=INDEX(H4:R14,U9+1,V9+1)
See it working!:
I've uploaded the file in case you want to check the formulas:
https://docs.google.com/spreadsheets/d/1wV8bn6B-jZ4jCxAonGdWFMluAEybzwkA/edit?usp=share_link&ouid=114417674018837700466&rtpof=true&sd=true
Please, notice this will work properly as far as there is a single closest match. If by any case two cells are both closest match, formula will return incorrect result.
And remember, as I said before, second table is just to explain the solution, you can delete it and everything will work.
You could create a 2nd table where you calculate the absolute or squared difference between your Poisson table values and the random value.
Then you can simply check for the smallest value in the 2nd table.
In your example, the 2nd table of differences could be created with the formula
=ABS($H$4:$R$14-$U$6)
Let's assume that this 2nd table is just below the 1st table, i.e. in H16:R26
Then the smallest value in this 2nd table is obtained by
=SMALL($H$16:$R$26,1)
from there you can get the row number through
=SUM(($H$16:$R$26=SMALL($H$16:$R$26,1))*($G$4:$G$14))
and the column number through
=SUM(($H$16:$R$26=SMALL($H$16:$R$26,1))*($H$3:$R$3))
Then, to find the closest match in the original table, you can use the INDEX() function and refer to the row and column calculated in the previous step.
You can of course skip all the intermediary steps and write everything into a single formula:
=LET(
table,$H$4:$R$14,
diff,ABS(table-$U$6),
closest,SMALL(diff,1),
closest_row,SUM((diff=closest)*SEQUENCE(ROWS(table))),
closest_col,SUM((diff=closest)*SEQUENCE(1,COLUMNS(table))),
INDEX(table,closest_row,closest_col)
)
Which looks like this:
Note: the last formula uses dynamic arrays and functions only available Excel O365.

Using vlookup while using web external data

Good afternoon,
I am pulling a fuel database from gasbuddy and trying to use the VLOOKUP function to grab address, prices and times last updated. However, all I am getting are #N/A (value not available) results. My code is below:
=VLOOKUP(
N5,
GasPriceSearch.aspx?typ_adv_fuel_limit_36,
COLUMN(B5),
FALSE)
I tried converting this information into a table and the formula works but I run into issues where new fuel prices are reported and it messes up the entire table. I would rather do it from the initial data without a table.
Thank you,
Jesse
There are several ways to achieve this. However, based on your data structure, a regular VLOOKUP won't work because VLOOKUP only searches to the right of the lookup value (i.e., the address) and, for example, the price is to the left of it. Thus, one possibility would be to restructure your data so that you have address, price, update, and so on. This would also circumvent the problem of having the price on a different row than the lookup value.
Another way to work with this data structure is to use the INDEX function:
=INDEX(array, row_num, [column_num])
Your array reflects the range where your data is stored that you want to look up; in your case, considering only price and station A:B. Since you've hidden some columns, it's hard to see what else is in this datasheet. But just adjust it to your needs of the data.
The row number can be hard coded. However, since you want to look up a specific value (i.e., address), you can use the MATCH function:
=MATCH(lookup_value, lookup_array, [match_type])
In this step you want to look up your address from column N in column B, where all stations are listed. You also need to specify the column you want to return. Again, you can either hard code it or use the MATCH function. With the match_type you can specify, for example, that you only want an exact match, i.e., match_type = 0.
To return the value "update" to the left of the address, your formula looks as follows:
=INDEX($A:$B,MATCH(N6,$B:$B,0),1)
To return the address itself (which is pretty much useless, since you already have it in column N), use the following formula with the adjusted column value from 1 to 2:
=INDEX($A:$B,MATCH(N6,$B:$B,0),2)
Lastly, your price information is one row above the address, you need to adjust the number of rows by -1 accordingly. That is, if your address is, for example, 4123 Town [...], you want to return column 1 of row 6 and not row 7:
=INDEX($A:$B,MATCH(N6,$B:$B,0)-1,1)
An alternative strategy would be to use the XLOOKUP function (only available in newer versions of Excel), which allows you to find values to the left of the lookup value. But also with this strategy you would have to deal with the problem of row differences. The OFFSET function could prove useful in this context, but it does not make the approach much easier than the INDEX function.

How to get smallest result from multi-criteria index/match function

I have a sheet with transactions. Each txn has an airport and an amount of fuel pumped. I have a second sheet with a list of locations, each row of which has min and max values for fuel bands (e.g, 1-500, 501-1000, min/max stored in separate columns), and each each of which have a price (for fuel per gallon).
I need to use the values per row in the first spreadsheet to search the second spreadsheet for a match on airport (ICAO code), greater than bottom of band, and less than top of band, and then return the unit price of fuel. The catch is that I can have multiple matches, and I need the smallest/lowest value.
I have some familiarity with Index/Match multi criteria arrays. So, I wrote the following and tried it:
=INDEX(FuelPrices!$D$2:$D$3398,MATCH(1,(FuelPrices!A:A=H2)*(FuelPrices!B:B>=N2)*(FuelPrices!C:C<=N2),0))
Where "Fuel" is my first sheet and "FuelPrices" is the sheet I'm looking up the values in. No matter WHAT I do it throws an #NA error. So, I figured maybe the problem was I was returning an array? I tried this:
=INDEX(FuelPrices!$D$2:$D$3398,SMALL(MATCH(1,(FuelPrices!A:A=H2)*(FuelPrices!B:B>=N2)*(FuelPrices!C:C<=N2),0),1))
Figuring it would give me the smallest value from the returned array. No go. I've tried some other tricks (using another Index function around the match) and nothing seems to work.
Basically I just want to get the function to return the lowest matching value for the provided criteria.
The short answer is that the < and > are the wrong way round. This does give an answer
=INDEX(FuelPrices!$D$2:$D$10,MATCH(1,(FuelPrices!$A$2:$A$10=H2)*(FuelPrices!$B$2:$B$10<=N2)*(FuelPrices!$C$2:$C$10>=N2),0))
if entered as an array formula using CtrlShiftEnter
I have changed all ranges to a small number of rows for testing purposes.
FuelPrices sheet
Fuel sheet
If you do want to find the smallest subject to the same conditions, you don't need index but can use small (or min)
=SMALL(IF((FuelPrices!$A$2:$A$10=H2)*(FuelPrices!$B$2:$B$10<=N2)*(FuelPrices!$C$2:$C$10>=N2),FuelPrices!$D$2:$D$10),1)
Or if you prefer you can use Aggregate (non-array formula)
=AGGREGATE(15,6,FuelPrices!$D$2:$D$10/((FuelPrices!$A$2:$A$10=H2)*(FuelPrices!$B$2:$B$10<=N2)*(FuelPrices!$C$2:$C$10>=N2)),1)

In Excel, how to return name associated with max value in a column?

I have text information in columns A through H. I have numerical data in columns I onward. My goal is to find the maximum numerical value in all columns I and onward, and return the corresponding name from column H.
For example, the maximum number in column J is 0.382, located at J88. So I want Excel to return the text content of H88.
I tried doing VLOOKUP but it seems like this was only working if my column of names/text is adjacent to my column of numerical values, so that was a dead end.
What you need is combination of INDEX() and MATCH():
=INDEX(H:H;MATCH(MAX(J:J);J:J;0))
This formula finds position of the highest value in the J:J column than returns cell on the same position in the H:H column.
VLOOKUP() doesn't work in this case because you need to mind order of the columns with the function, if you swapped them it would work just fine.
Just to elaborate on #M.Douda's answer, since it may not be clear that this approach can cause unintended mistakes if you have more than one maximum.
index() and match() is definitely the way to go, but you need to be careful if there is more than one maximum (i.e. if both J88 and J89 have a value of 0.382). With the match_type parameter equal to 0, values can be in any order and Excel will return the first match of the search, but only that one.
Note: If you wanted to keep using vlookup(), a simple solution would be to add one column in the end (to the right) where you copy from column H (but this is obviously redundant, not recommended). It also suffers from the maxima problem.

Excel VLOOKUP returning same value in all rows

The vlookup function appears to be broken. It is returning the same value for all lookups, but it should not.
I have it set like so:
=VLOOKUP(A3, Asset_Mapping!A$2:B$673, 1)
Where the lookup value is in the B column and the result is in the A column.
I use the $ so the rows are not auto-updated to A3:B674 etc as I paste the formula down the rows. However, even if I manually enter that formula into the next row, it is not finding the correct value.
IF i remove the "$", the correct values are found for the first rows where the values fall within the modified range (e.g. Asset_Mapping!A3:B674) but eventually as expected it stops finding the values as the range is invalid.
What am I doing incorrectly here? I have formulas set to auto-calculate.
Without testing on your actual data it's hard to confirm this will work but add the false parameter. This will find exact matches and not the first partial match.
=VLOOKUP(A3, Asset_Mapping!A$2:B$673, 1, false)
Collating the points together and clarifying the formula
Parameter 1: The value you are looking for
Parameter 2: The table with the data. First column is the value you are looking for.
Parameter 3: The column number of the value you want to show.
Parameter 4: If you want an exact match or partial match.
#Jeeped made the point of ordering data to get more reliable results. Good advice.
Andres has the right idea, but there is a faster way to fix the problem.
If it is returning the same value over and over again for your whole range, you probably have your Calculation Options set to "Manual".
Go into Formulas on the top ribbon and choose Calculation Options. There, you can change your calc method to "Automatic".
Also lookup value must be in first column.
Where the lookup value is in the B column and the result is in the A column.
VLOOKUP always lookup in the left-most column and returns a value from the column number specified. If you want to reverse the lookup/return order then use INDEX(..., MATCH(...))
=INDEX(Asset_Mapping!A$2:A$673, MATCH(A3, Asset_Mapping!B$2:B$673, 0))
Note that you were using a sorted, binary lookup; I've changed this to an exact match lookup which does not require sorted data.
Just in case adding a solution to this topic.
Don't know why in big tables Vlookup and Index+Match tend to show just the value of the first result in all the other cells.
In my case to fix this, after I've copied the formula in the whole range, I choose any cell containing it, press F2 and then Enter. It kind of forces excel to process everything.
I've been working on this for a week with no results. I've created this same spreadsheet for another apartment community without any issues, but for some reason, I cannot get the proper results in this spreadsheet. I've tried vlookup as well, but that didn't help either. any more advice?
Formula
Result and lookup vectors

Resources