How to find multiple minimum values in excel without repeating? - excel

Image:
In Excel, column J has a formula IF(H32>0,D32,MIN($S$32:S32)). For MIN($S$32:S32)), it is finding the lowest value in column S. However, if you see cell J39, it repeats using the same minimum value in J37.
I am looking to modify the function I created where the minimum value won't repeat itself. For example, the next minimum after 57.87 in column S is 75.82. Therefore, 75.82 should appear in cell J39.

You can use the RANK formula for this. With RANK, you can choose the n-th minimum value from Column S.

Related

Function to search for specific number and then to further search for the prefix

I have a huge amount of data to process in which 4 points with a related prefix needs to be subtracted from each other.
Data consists of ID and x value
Example
ID = 290.12, 290.03, 290.06, 290.09, 300.12, 300.03, 300.06, 300.09, 301.12, 301.03, 301.06, 301.09
(let's call prefix a "ring number" and suffix time on the clock)
X value = any numerical value for each ID assigned
What I'm hoping to do is to search for the first number before the dot i.e. 300 and then subtract the value of 300.06-300.12 in one cell and in another cell 300.03-300.09.
(The subtraction is just an example, how I need to manipulate with the numbers is slightly more complicated, but I got this one under control)
This is my actual Data and what I need to produce is to the right of the raw data. At the moment, I'm doing it manually for each set of "rings"
Anyone knows how to approach this? I'm thinking vlookup, but I'm not very proficient in excel.
New Excel
I tried vlookup, but I don't know how to construct the formula and I run out of ideas.
Edit:
I found out that REDUCE is no requirement in this case, so it can be shortened to:
=SQRT(SUM(((INDEX(B:D,XMATCH(I3+0.09,A:A),SEQUENCE(1,3))-INDEX(B:D,XMATCH(I3+0.03,A:A),SEQUENCE(1,3)))^2)))
You could change +0.09 and +0.03 to your needs and may reference them using LET() for easy maintaining:
=LET(id,I3,
_id1,0.09,
_id2,0.03,
SQRT(SUM(((INDEX(B:D,XMATCH(id+_id1,A:A),SEQUENCE(1,3))-INDEX(B:D,XMATCH(id+_id2,A:A),SEQUENCE(1,3)))^2))))
Previous answer:
=LET(
id,I3,
_id1,0.09,
_id2,0.03,
SQRT(
REDUCE(0, SEQUENCE(1,3),
LAMBDA(x, y,
x+((INDEX(B:D,XMATCH(id+_id1,A:A),y)
-INDEX(B:D,XMATCH(id+_id2,A:A),y))
^2)))))
This formula looks for the matching value of the id value I3 + _id1 minus the matching value of id value + _id2 for columns B to D and adds the ^2 results per column. Then it calculates it's square root.
You can change _id1 and _id2 to your needs.
To calculate the Delta (as shown) at once you could use:
=LET(id,I3,
_id1,0.09,
_id2,0.03,
_id3,0.12,
_id4,0.06,
x,SQRT(SUM((INDEX(B:D,XMATCH(id+_id1,A:A),SEQUENCE(1,3))-INDEX(B:D,XMATCH(id+_id2,A:A),SEQUENCE(1,3)))^2)),
y,SQRT(SUM((INDEX(B:D,XMATCH(id+_id3,A:A),SEQUENCE(1,3))-INDEX(B:D,XMATCH(id+_id4,A:A),SEQUENCE(1,3)))^2)),
(x-y)*1000)
You can have a column of unique values of the integers and a new column where you reference these values as id and drag down the formula to get your row by row result
In another column you can refer to these columns and sort per the second column using SORTBY()

Excel Formula: Return value from array with multiple criteria

Suppose the following series:
I am trying to find the latest non 1 value that precedes the latest 1.
In this case it should return 3 and not 4.
1 being the minimum value I have tried to use MATCH(MIN(range),range,0) and add 1 to get the value I needed, but the minimum function gets stuck on the first occurrence of the minimum.
Try
=INDEX(B1:P1,1,MATCH(1,(OFFSET(B1:P1,,-1)=1)*(B1:P1>1),0))
Where B1:P1 is your data range. Of course it is an array formula (SHIFT+ENTER).
Hope that helps.
I can't see a short and snappy answer to this but here is one suggestion assuming the data starts in column A
=INDEX(2:2,AGGREGATE(15,6,COLUMN(INDEX(2:2,MATCH(1,2:2,0)):INDEX(2:2,MATCH(999,2:2)))/(INDEX(2:2,MATCH(1,2:2,0)):INDEX(2:2,MATCH(999,2:2))>1),1))
If the range didn't start in column A, you would have to subtract the number of the column before the first column of the range from the column number returned by the AGGREGATE to get the correct index value relative to the start of the array e.g. for B2:Z2
=INDEX(B2:Z2,AGGREGATE(15,6,COLUMN(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):INDEX(B2:Z2,MATCH(999,B2:Z2)))/(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):INDEX(B2:Z2,MATCH(999,B2:Z2))>1),1)-COLUMN(A:A))
To be honest it wouldn't be worth using a MATCH to find the last number in the range unless the number of cells in the range was very large, so the formula for B2:Z2 would just be
=INDEX(B2:Z2,AGGREGATE(15,6,COLUMN(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):Z2)/(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):Z2>1),1)-COLUMN(A:A))
Formula starting column A
Formula starting at column B

How to find the LOCATION of the K'th largest value of a range in Excel?

The question is as in the title. Note that LARGE(range, k) doesn't tell me the location of the value, and attempting to search for it using INDEX can fail in the presence of duplicates. Is there another way?
Depending on the original data and whether you're in a position to modify the workbook, one way is to use a "helper column" to give you unique values by adding a very small row-dependent value to your data, eg the row number divided by 1000000. As long as the additional value isn't greater than the smallest true difference in data values it will not change the rank ordering of the data, but it does make it unique and has the benefit of being relatively "easy".
In this example B3:B17 contains mostly integer values, a couple of ".5" fractions, with some duplication. I have set C3:C17 as the helper column, in which I'm adding and adjustment value of the row number * 0.0000001. As the smallest step change in the genuine data is much larger than the largest adjustment value, there is no risk of incorrect ordering - only an imposition that where the original data is exactly the same, ordering is now based on location in the table.
Column F lists the largest helper values (eg cell F3 formula "=LARGE($C$3:$C$17,E3)"), column G finds the row that value is in (cell G3 formula "=MATCH(F3,C:C,0)"), and then your output table looks in the genuine data using this row number.
what if you use one column and type=IFERROR(RANG.eq(K2;"range of K")+SUMPRODUCT(--(K2=K$2:K$74"ex");--(K2<K$2:K$74));"") and one column =IFERROR(COUNTIFS(M2"new column":$M$74;M2)+M2-1;"").
After that all numbers in K will be ranged even if equal and you can use LARGE

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"

Excel - Cell left of the median cel

I have an array in excel: C2:C20. I want to find the cell with the median and then find the value of a cell in column A corresponding to the row. Some of the cells in the array might not contain anything. How do I do that?
EDIT:
The table is about observations.
The A column is about the name of the observation.
Sorry for the Danish language.
Hyppighed = frequency
Summeret hyppighed = summerized frequency
Sample table:
Result table when using the suggested functions
This will return the first median value found in C2:C20 and return the corresponding cell in column A.
=INDEX(A2:A20,MATCH(MEDIAN(C2:C20),C2:C20,0),1)
If you know exactly what you are looking for you can replace MEDIAN(C2:C20) with whatever you are searching in the Array contained in column C. If it is a string you are searching use "" around your text.
EDIT:
The reason you are getting N/A with your data set is because there is no exact match to the Median. In order to resolve this you need to replace the 0 with a 1 if you want a value higher than or equal the median or -1 if you want a value lower than or equal to the median.
Try this and it will give you the next highest median value if there is no match.
=INDEX(A2:A20,MATCH(MEDIAN(C2:C20),C2:C20,1),1)
For the purposes of doing an index look up the above method using the median function is inferior,
barry houdini made a great suggestion below which will choose the median value available or the next lowest one regardless of sorting...
=INDEX(A2:A20,MATCH(SMALL(C2:C20,INT((COUNT(C2:C20)+1)/2)),C2:C20,0))
or alternatively if you wanted to choose the highest one if the median is not available rather than the lowest one you could do
=INDEX(A2:A20,MATCH(LARGE(C2:C20,INT((COUNT(C2:C20)+1)/2)),C2:C20,0))

Resources