Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9788

Google Sheets "Query" issue with rounding

$
0
0

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-postive, 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)

Viewing all articles
Browse latest Browse all 9788

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>