I am using a formula of:
=INDEX(QUERY($I$19:$I$30,"select I where I >= " & rounddown(D$27,2) & " order by I limit 1",0),1)
In D27
I have a value of: 0.8190
In I19:I30
I have a series of values:
0.7400
, 0.7500
, 0.7800
, 0.8000
, 0.8200
, 0.8400
, 0.8700
, 0.9000
, 0.9300
, 0.9500
, 0.9800
, 1.0000
I am trying to select the row in I that is closest, but not greater than.
Expected outcome would be: 0.8000
since rounddown(0.8190,2)
is 0.81
, which is less than 0.8200
, but greater than 0.8000
.
However, it keeps returning 0.8200
.
I've tried a bunch of numbers in D27, and it keeps acting like the >=
evaluation is rounding up. Is there a logic/syntax issue in my formula, or is this some quirk in evaluation on Google Sheets?
Basing this solution from another post: https://webapps.stackexchange.com/questions/69743/find-the-closest-value-equal-or-greater-in-a-range-in-google-spreadsheets
----- [UPDATE] -----
I indeed put the logic backwards based on false-near-positive, as well as an unclear goal in original post. The correct formula is:
=QUERY($I$19:$I$30,"select I where I <= " & (C$27) & " order by I DESC limit 1",0)
=rounddown(0.819,4)
. My result = 0.8190 (which is kind of what I expected since there are 4 decimal places), yet you get 0.81. Would you care to double check your formula? One of us (quite possibly me) is wrong and this will affect your query outcome.>=
(greater than or equal to). 0.80 is less than 0.81 so it is excluded; the next value is 0.82, which is greater than 0.81, so the result is 0.82.<=
, the query finds that the first value (0.74) will satisfy the condition. I agree, you need to sortdesc
in the query condition. Well done.