Boolean to number
Hello all,
Is there a way to convert a TRUE/FALSE boolean value in Numbers to an integer (1/0)? Elegantly, without using the IF function, which is slow.
Thank you!
Vidu
Hello all,
Is there a way to convert a TRUE/FALSE boolean value in Numbers to an integer (1/0)? Elegantly, without using the IF function, which is slow.
Thank you!
Vidu
If you are trying to use it in a function that won't accept it as a boolean, multiplying it by 1 in the formula will do it except it will also put a blue triangle in the cell. If you are trying to avoid the blue triangle, your choices are limited. There is no elegant conversion that I am aware of. I don't know why Numbers feels the need to warn about using true/false as numbers but it does. And it does not give you the option of ignoring those blue triangle warnings, which makes it doubly painful.
If it is a column of booleans (column B for example), you can insert a new column and use the formula =B*1 which will convert the booleans to numbers (with the blue triangles). Use that column of numbers in your downstream formulas then hide the column after everything is set up.
There are plenty of non-elegant formulas in addition to IF or IFS. Maybe COUNTIF would be a contender on speed. It is a concise formula at least. IF is almost assuredly faster, though.
=COUNTIF(B2,TRUE)
If you are trying to use it in a function that won't accept it as a boolean, multiplying it by 1 in the formula will do it except it will also put a blue triangle in the cell. If you are trying to avoid the blue triangle, your choices are limited. There is no elegant conversion that I am aware of. I don't know why Numbers feels the need to warn about using true/false as numbers but it does. And it does not give you the option of ignoring those blue triangle warnings, which makes it doubly painful.
If it is a column of booleans (column B for example), you can insert a new column and use the formula =B*1 which will convert the booleans to numbers (with the blue triangles). Use that column of numbers in your downstream formulas then hide the column after everything is set up.
There are plenty of non-elegant formulas in addition to IF or IFS. Maybe COUNTIF would be a contender on speed. It is a concise formula at least. IF is almost assuredly faster, though.
=COUNTIF(B2,TRUE)
You could use MATCH & INDEX or one of the LOOKUP functions, but I doubt it would be significantly faster than IF.
Or try IFS(B2,1,true,0) Where B2 is the cell containing a TRUE or FALSE result.
IFS tests each value in turn, presents the result of the first that tests 'true.
In this formula, if B2 contains 'true' the formula returns 1, and exits.
If B2 contains 'false', ifs moves on to the next pair. 'true' returns 'true', IFS returns the value paired with that test ( o ) and exits.
Regards,
Barry
Badunit and Barry,
Thank you both for your replies. Yes, i am trying to multiply a boolean value in an equation and the blue triangle is annoying... IFS was the workaround. Hopefully this will be fixed in the future.
Best regards,
Vidu
" Hopefully this will be fixed in the future."
The warning triangle has been a feature acting in the same manner since the introduction of Numbers version 1 (the example below is from Numbers '09 v2.3).
Changing that behaviour requires a change in the software, something that is outside the scope of these user to user communities.
Send your Feature Request directly to Apple via the Provide Numbers Feedback menu item in the Numbers menu.
Regards,
Barry
Barry,
Is there a way to ignore the warning in the latest versions? The warning itself isn't so bad but I see no way to get the blue triangle to go away. It comes up in other functions, too, like SMALL or LARGE when the range includes cells that are not numbers. Some formulas to return multiple matching values rely on those functions and it makes for more complicated formulas just to avoid blue triangles.
Boolean to number