Forum Discussion
JPScottIII
Nov 13, 2021Copper Contributor
MIN function exclude "Zero" values - Non Consecutive group of cells
I am struggling with ignore zero values when the group of cells to be tested is not a consecutive range The function "=MIN(D7,M7,V7,AE7,AN7)" works fine but I want to ignore lowest value if AE7 a...
Martin_Angosto
Jul 11, 2024Iron Contributor
Interesting!
Just replacing MIN by SMALL to meet Tom's requirement of retrieveing the second smallest number and beautiful alternative.
Martin_Angosto
Jul 11, 2024Iron Contributor
And just to add to the pot, an interesting small challenge:
Imagine range from large negative to large positive. We aim to retrieve the second smallest positive number from a discontinued range of cells. Hundreds of cells to take into account. The second smallest number retrieved (k) should not be equal to k -1, nor k +1. That is, a unique second smallest positive (non-zero) number.
See initial structure:
=SMALL(LET(continued,HSTACK(A1,C1,E1,G1,I1),FILTER(continued,continued>0)),2)
In the example, 8 should be the value retrieved and not 1.
Also, how to set the HSTACK or similar in an efficient way (hundreds of cells, cannot be entered mannually - one space between each one always).
- SergeiBaklanJul 11, 2024MVP
So, If I understood correctly
=LET(a, {-1,1,1,8,9}, f, FILTER(a,a>0), SMALL(HSTACK(TAKE(f,,1),UNIQUE(f,1,1)),2) ) =LET(a, {-1,1,1,8,8,9}, f, FILTER(a,a>0), SMALL(HSTACK(TAKE(f,,1),UNIQUE(f,1,1)),2) )
- Martin_AngostoJul 11, 2024Iron Contributor
That is the "trick":
The first positive number is counted to be the first (independently if it is not unique).
That is, 1 is the first positive number. It is repeated, but it would be still counted as the first positive number.
However, for the sake of finding the second smallest number, this one should not be repeated. The uniqueness requirement is only affected by the second smallest positive number, the one we are looking to retrieve. Not for the first smallest positive value.
- SergeiBaklanJul 11, 2024MVP
I missed a bit , what exactly do you mean
for {-1,1,1,8,9} positive distinct are {8,9}, first smallest is 8, second smallest is 9
for {-1,1,1,8,8,9} positive distinct are {9}, first smallest is 9, second smallest doesn't exist
- Martin_AngostoJul 11, 2024Iron Contributor
What about the retrieval of the second smallest postive unique number?
In a range {-1,1,1,8,9} it should be 8.
In a range {-1,1,1,8,8,9} it should be 9.
Note the aim is not the second smallest number by position (which would be 1) but for uniqueness (first unique second smallest value).
- SergeiBaklanJul 11, 2024MVP
Not to enter hundred of references it shall be some logic defined, i.e. take every third cell or like. If no such logic when only manually.