Call 'Large' ref, grab value from column in referenced row - excel

Let's say I have a few columns, five for example. Multiple rows. For each individual row, on column A and B, I have two strings that I would like to reference. Columns C and D add up into column E, which totals the two values.
What I'm looking to do is reference the largest values in the chart, pull that number, and also return the two strings in columns A and B.
I know you can pull the largest number in range x,y in col E with =LARGE(Ex:Ey,1), but how does one reference the row that the number represents?
Let's say for reference that the two strings in the sixth row are Alpha and Bravo, and this sixth row contains the largest value (26 for example) that I want to pull.
I'm looking for a way to get the output 26 Alpha Bravo, if that's possible. I'm making a list going from largest to smallest, so I'm looking for a way to incorporate LARGE in there as well - looking to pick the 10 largest values and their respective strings.
Any thoughts?

I'm looking for a way to get the output 26 Alpha Bravo, if that's possible.
Please try:
=MAX(E:E)&" "&INDEX(A:A,MATCH(MAX(E:E),E:E,0))&" "&INDEX(B:B,MATCH(MAX(E:E),E:E,0))

try =MATCH(LARGE(A1:A6, 2),A1:A6,0)
Large returns the value you are looking for, and match will find the row it is in. Use the row starting in row 1 for match to give you the physical row, not the instance within the list. Match with the third argument set to zero is basically a find first, and the Match function can also accept wildcards.

Related

Appending two lists in excel

I have been trying and searching how to append two lists in excel to use in a formula. The lists do not exist in columns, they are created using a formula. I want to combine the two lists in a single one, not to show the values but to use the new list in a formula. I am using excel 365 (UNIQUE function). Let me replace my initial text by a real small case.
I have an excel file with 3 work sheets. Sheet1 is:
Sheet2 is:
Now I want to run some analysis in Sheet3. In my example I want to count how many unique values from column A have column B containing one of the letters 'a', 'b, 'c', or 'd'. For instance, in Sheet1, the letter 'a' appears in all rows. Column A has 3 unique values. So my result for 'a' is 3. The letter 'b' does not appear for the case where column A is '3'. Therefore the result for 'b' is '2'.
So I create a Sheet3 to show my results. The first column contains a list of letters {a, b, c, d}. I then use the formula:
=COUNT(UNIQUE(FILTER(Sheet1!$A$1:$A$100, ISNUMBER(SEARCH(A1, Sheet1!$B$1:$B$100)))))
From inside out: the SEARCH function looks in cells B1 to B100 (I can live with specifying a larger range) where is the position of the value specified in column A (of the current sheet). If it does, then SEARCH returns a number. I check if the return value is a number (ISNUMBER) and use this to filter values in column A of Sheet1. I then apply the UNIQUE function to these values and finally count them.
Then I do the same with values in Sheet2. And it works. This is the output:
Column B is the number of unique values (as specified above) from Sheet1 and Column C the same from Sheet2.
So far so good. But now I want to have the counting of unique values globally. Not for each Sheet. One cannot just add the values from column B and C, as there might be an overlap. For example, the result for 'a' should be 3, not 5.
The solution here would be to grab the two unique lists (one from Sheet1 and the other from Sheet2), join them, UNIQUE this new list, and count. How do I join them ? That is my question.
Note that this 'counting of unique values' is just an example. I might want to find the maximum, or sort them, or find only prime numbers, or the average, or the median, or something else. So I need a general approach to join the results.
I got options close to a workable thing when all the data is in the same worksheet.
Finally, note that the data size I have is not huge, but it is large (thousands of lines at the most).
Here is something you could try:
=LET(x,{"A","B","C"},y,{"D","E"},z,CHOOSE({1,2},x,y),cnt,MAX(COUNTA(x),COUNTA(y)),seq,SEQUENCE(cnt*2),final,INDEX(z,MOD(seq-1,cnt)+1,CEILING(seq/cnt,1)),FILTER(final,NOT(ISERROR(final))))
Here both 'x' and 'y' variables are placeholders for your two (vertical) arrays. In this case I used: {"A","B","C"} and {"D","E"}. Assuming you just want to place the 2nd array directly under the 1st one, the above suggestion does just that:

Excel Column Missing Data

I have an excel spreadsheet that has a Name Date match in two columns for one list, and the same name date match for two columns in a 2nd list.
One list is longer than the other, how can I find the data that is missing in the matching date/name from the other list?
For instance let's say
List 1 List2
1/2/2012 Tim 1/2/2012 Tim
2/2/2012 Jill 2/2/2012 Jill
3/2/2012 Bob
So basically I need to search list one and find out that List 2 is missing "3/2/2012 Bob" both the dates and names are in their own columns.
How do I do this? Keeping in mind that these lists have no order and that it is possible that someone in list2 might show up in list1 just not on the same row.
If List 1 is in columns A and B, and List2 is in columns C and D, then select an area the same size as List 1 (or the size of List 1 minus List2--make sure it has 2 columns) and enter this as an array formula (ctrl+shift+enter):
=IFERROR(INDEX(A2:B4,SMALL(IFERROR(MATCH(A2:A4&B2:B4,C2:C3&D2:D3,0)+ROWS(A2:A4),ROW(INDIRECT("1:"&ROWS(A2:A4)))),ROW(INDIRECT("1:"&ROWS(A2:A4)))),{1,2}),"")
Expand the rows as needed. Also, you'll need to format the first output column as a date.
EXPLANATION UPDATE
The Evaluate Formula dialogue is helpful for breaking down complicated formulas. Select the cell with the formula and press alt then T then U then F ("TUF" for tough formulas...).
Start with the MATCH function. Since we're looking for a date-name match, concatenate the name and date columns with &. MATCH will tell us which pairs in List 1 are also in List2 (specifically where--we'll get an array of indices in List2 where the matches were found in List 1). If a match is not found, it will return #NA. So for the OP's example MATCH will return {1;2;#NA} (the first value in the List 1 array is in position 1 in List2, the second value is in position 2, and the third value was not found in List2).
The second argument in the inner IFERROR is an array of the indices of List 1. ROWS returns the number of rows in a range, INDIRECT returns a safe (meaning it won't be accidentally deleted or moved) reference to rows 1 through the number returned by ROWS, and ROW returns the row number of each of the rows--so in the OP's example, this is {1;2;3}.
We want the elements from List 1 that were not found in List2, so we add the number of rows in List 1 to the non-error MATCH results. This will send those values to the end of the array returned by SMALL. For the OP's example, the array passed as the first argument to SMALL is {4;5;3}.
Now we want to bring the indices of interest to the top using SMALL. We use ROW(INDIRECT("1:"&ROWS(A2:A4))) again as the second argument in SMALL to sort the array smallest to largest. For the OP's example, the resulting array is {3;4;5}.
We then pass that array to INDEX as the "row_num" argument and {1,2} as the column argument. INDEX will then pull both columns from the range that we give as its first argument for each row in the array that resulted from SMALL. The values at the end of the array that resulted from SMALL are larger than the number of rows in List 1 (since we added ROWS(A2:A4) to them), so they will result in #REF! errors. These correspond the the elements that returned a match in the MATCH function. We wrap this with yet another IFERROR to blank out the errors.

Array of unique values and matching

Suppose several dices (3 for example) thrown each time. It also could be more than six possible outcomes per "dice", but I took six for better illustration.
1). Columns E or G:
Lookback is simply the size of an array. Arrey should include only unique values and ignore zero values. The tricky thing is that the series of observations are sorted from oldest to newest, and values of an array must be updated based on the newest series of 3 numbers (largest row number in the selected range).
So the parameters of a function should include (array range, max value, array size).
What I need to do is simply to take all values from 1 to 'max value' (1,2,3,...) and subtract all values from an array. In other words, take only those values, which are not included in array for a given range. Finally, type them in ascending order using comma delimiter.
2). Columns D or F:
Here we take any particular range of values, and compare it with our comma delimited list. If there is a match, then type matched numbers similarly using comma delimiter.
I suggest splitting out a lookup table in col h to m with 1,2,3,4,5,6... Across the top in h1 to m1 then in each row you can do a hlookup( h1, a3:c3, 1,false) in cell h3 to m3. This will return either a number or error, you could further wrap this function in an if function if(iserror(hlookup...),h1, ""). This would give you a row of numbers that it does not find in your dice roll which you could concatenate to get what your looking for.

Sort Order formula to alphabetise in Excel

I am currently drawing up a spreadsheet that will automatically remove duplicates and alphabetize a list:
I am using the COUNTIF() function in column G to create a sort order and then VLOOKUP() to find the sort in column J.
The problem I am having is that I can't seem to get my SortOrder column to function properly. At the moment it creates an index for two number 1's meaning the cell highlighted in yellow is missed out and the last entry in the sorted list is null:
If anyone can find and rectify this mistake for me I'll be very grateful as it has been driving me insane all day! Many thanks.
I'll provide my usual method for doing an automatic pulling-in of raw data into a sorted, duplicate-removed list:
Assume raw data is in column A. In column B, use this formula to increase the counter each time the row shows a non-duplicate item in column A. Hardcord B2 to be "1", and use this formula in B3 and drag down.
=if(iserror(match(A3,$A$2:A2,0)),B2+1,B2)
This takes advantage of the fact that when we refer to this row counter in our revised list, we will use the match function, which only checks for the first matching number. Then say you want your new list of data on column D (usually I do this for display purposes, so either 'group-out' [hide] columns that form the formulas, or do this on another tab). You can avoid this step, but if you are already using helper columns I usually do each step in a different column - easier to document. In column C, starting in C3 [C2 hardcoded to 1] and drag down, just have a simple counter, which error-checks to the stop at the end of your list:
=if(C2<max(B:B),C2+1," ")
Then in column D, starting at D2 and dragged down:
=iferror(index(A:A,match(C2,B:B,0)),"")
The index function is like half of the vlookup function - it pulls the result out of a given array, when you provide it with a row number. The match function is like the other half of the vlookup function - it provides you with the row number where an item appears in a given array.
Hope this helps you in the future as well.
The actual reason that this is going wrong as implied by Jeeped's comment is that you can't meaningfully compare a string to a number unless you do a conversion because they are stored differently. So COUNTIF counts numbers and text separately.
20212 will give a count of 1 because it is the only (or lowest) number.
CS10Z002 will give a count of 1 because it is the first text string in alphabetical order.
Another approach is to add the count of numbers to the count if the current cell contains text:-
=COUNTIF(INDIRECT("$D$2:$D$"&$F$3),"<="&D2)+ISTEXT(D2)*COUNT(INDIRECT("$D$2:$D$"&$F$3))
It's easier to show the result of three different conversions with some test data:-
(0) No conversion - just use COUNTIF
=COUNTIF(D$2:D$7,"<="&D2)
"999"<"abc"<"def", 999<1000
(1) Count everything as text
=SUMPRODUCT(--(D$2:D$7&""<=D2&""))
"1000"<"999"
(2) Count numbers before text
=COUNTIF(D$2:D$7,"<="&D2)+ISTEXT(D2)*COUNT(D$2:D$7)
999<1000<"999"
(3) Count everything as text but convert numbers with leading zeroes
=SUMPRODUCT(--(TEXT(D$2:D$7,"000000")<=TEXT(D2,"000000")))
"000999" = "000999", "000999"<"001000"

Select a cell value from a range based on criteria

I'm trying to figure out a sleeker method for determining the value of a cell based on criteria defined in a given range. To put it bluntly, I have a column for standard viscosity, standard temperature, and measured temperature. I'm needing to create a fourth column that will select the standard viscosity based on the measured temperature. For example, if measured temperature is greater than or equal to 0oC and less than 1oC: return standard viscosity for 0oC.
My issue is that I have a large range and find it to tedious to create a custom expression for each range. I've created a nightmarish function that was composed of IF(AND()) statements but find this exhausting, especially if I try to create an expression for a 0-200oC scale in single digit increments.
Here is a sample of a code that works but is quite cumbersome:
=IF(AND(G8>=$C$7,G8<$C$8),$D$7,0)+IF(AND(G8>=$C$8,G8<$C$9),$D$8,0)+....
or
=IF(AND(measured temp>=0,measured temp<1),$D$7,0)+IF(AND(measured temp>=1,measured temp<2),$D$8,0)
How could I approach this in a sleeker manner?
You can achieve this by the VLOOKUP function.
=VLOOKUP(G8;$C$7:$D$...;2;TRUE)
Replace the three dots with the index of the last row of your table.
The first argument of VLOOKUP is the value to search for; the second argument is the range whose first column is to be searched for the value; the third argument is the index of the column containing the values to return (within the range, so 2 means the second column within the range, which is D in your case); TRUE means that you do not want to search for an exact match, but that the column to be search is an ordered list of values defining intervals.
Edit:
With MATCH and OFFSET (guessed, not tried), if column with result values is left relative to column of criterion values:
=OFFSET($C$7;...;MATCH(G8;$C$7:$C$...;1) - 1)
Replace the first three dots with the position of the result column, relative to column C (so 1 if it's column D, and -1 if it's column B), and the second three dots with the index of the last row of your range, as above.
Edit2:
INDEX instead of OFFSET is even better, se pnuts's answer and the comment below:
=INDEX($D7:$D...;MATCH(G8;$C$7:$C$...;1))
If your measured temperature is say in F2 and your data table is A:C please try:
=INDEX(A:A,MATCH(F2,C:C))

Resources