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

how to use MAX in a query and use the result as a number in Google Sheets?

$
0
0

If I write a formula using query and limit it to one result, I can then use it as a number, for instance

=1+QUERY(B13:F18,"SELECT C WHERE (B='Banana') LIMIT 1")

But if I want to use the maximum value the same way, it gives me an error:

=1+QUERY(B13:F18,"SELECT MAX(C) WHERE (B='Banana')",0)

Function ADD parameter 2 expects number values. But 'max' is a text and cannot be coerced to a number.

Column C only contains numbers! If I exclude the addition I see that it is adding an unwanted label "max" above the max value. I am putting 0 for the third parameter to query, which I thought meant I wouldn't have any header lines. I also tried "" and that didn't work either.

I thought maybe it was treating the result as an array, so I wrapped the whole thing with:

=INDEX(QUERY(...), 0, 1)

Which I expected to skip over the row containing max. But I got the exact same output!

How do I extract just the number so I can use it in the formula?


Viewing all articles
Browse latest Browse all 9782

Trending Articles



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