How to convert TRUE and FALSE to 1 and 0 in Excel
Formula (Excel and Google Sheets)
=--B2Put two minus signs in front: =--B2 turns TRUE into 1 and FALSE into 0.
- Result on the example
- one result per row in
C2, filled down toC8 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in C2, filled down to C8. Change any input and the result updates, or edit the formula to experiment.
How it works
The double minus is two negations: -TRUE is -1 and -(-1) is 1, while FALSE stays 0. Any arithmetic converts a logical value to a number; this is the shortest form, and the one you will see inside SUMPRODUCT.
=--B2Result1
B2TRUEThe value in B2.
-B2-1Makes the value negative.
--B21Makes the value negative.
In Google Sheets
The same formula works in Google Sheets: =--B2. We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =IF(B2,1,0) | 1, 0, 1… | Spells the conversion out and is easy to change to other values, like "Yes" and "No". |
| =B2*1 | 1, 0, 1… | Multiplying by 1 (or adding 0) converts the same way. |
Common mistakes
- SUM skips TRUE and FALSE in a range, which is why you convert them:
=SUMPRODUCT(--B2:B8)counts the TRUEs. - The text "TRUE" from a CSV import isn't a logical value, and
--"TRUE"returns #VALUE!. Compare it instead:=--(B2="TRUE").
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Convert TRUE and FALSE to 1 and 0
C2, turn the TRUE or FALSE in B2 into 1 or 0. Fill down to C8.Questions
How do I count TRUE values directly?
=COUNTIF(B2:B8,TRUE).
How do I turn 1 and 0 back into TRUE and FALSE?
Compare with 1: =C2=1.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.