Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boolean switch from 1/0 to 0/1

I quite often use a formula like:

=1*(A2=G2)

If A2 and G2 are the same then it returns 1 - otherwise it returns 0.

I realise it is trivial with an IF function but I'm specifically interested in this format of function using 1*.

How can I amend it so that if A2 and G2 are NOT the same it returns 1, otherwise 0?

like image 808
whytheq Avatar asked Dec 10 '22 20:12

whytheq


2 Answers

Use the <> operator to check inequality:

=1*(A2<>G2)
like image 116
agold Avatar answered Dec 25 '22 16:12

agold


You can just subtract the result from 1, to invert it

=1-1*(A2=G2)
like image 35
Ernestas Mitkus Avatar answered Dec 25 '22 14:12

Ernestas Mitkus