Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy in Excel comparing 1<' or comparing any number to any text with < results in true?
    primarykey
    data
    text
    <p>In Excel <code>1234 &gt; qwer = false</code>, but <code>1234 &lt; qwer = true</code>. Having worked with nullable types in C# I would expect both statements to return <code>false</code> like when comparing values to nulls.</p> <p>What is rationale behind that? Is it documented somewhere?</p> <p>My first thought was that Excel internally converts numbers to strings and then compares strings, but then:</p> <p><code>'129 &lt; '11a = false</code> - when left part is entered as text</p> <p><code>129 &lt; '11a = true</code> - when left part is entered as a number</p> <p>In VBA <code>variant</code> type comparison works the same way as on spreadsheets</p> <pre><code>Sub CompareNumberAndText() Dim a, b, c at = "129" an = 129 b = "11a" ct = at &lt; b 'false cn = an &lt; b 'true End Sub </code></pre> <p>I am developing a library with a type similar to Excel cell and wanted to make behavior as close to Excel as possible, but these Excel comparison results are counter-intuitive. I would throw an error or return false in this case.</p> <p>I could imagine a hypothetical situation when in column A I calculate some value by dividing two numbers, e.g. P/E ratio, but for negative E I put "n.m.". Then in column B I check if P/E > some_value, I will get true for n.a. If the exercise is to find expensive stocks, then showing ones with negative earnings makes some (but very little) sense and could be useful for further manual one-by-one analysis when there are 20 stocks. But if there are 2000 ones and I calculate some aggregates, this could go unnoticed.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload