Convert TRUE/FALSE to 1/0 in Excel

Reading time: 2 minutes

Do you know you can convert the result of a logical test, TRUE or FALSE, to 1 or 0? It’s straightforward and highly useful for utilizing functions like SUM. Two techniques can be used

  1. Multiply the outcome of a logical test by 1
  2. Apply the hyphen method to transform the result (my favorite)👍

Result of a logical test in Excel

In Excel, a logical test returns TRUE or FALSE. For instance, to determine if a customer is 21 years-old or older, we can write the following test with an absolute reference to the limit cell.

Logical test age greater than 21

Training articles

How to convert the test to a numeric value?

Method 1: Multiply by 1

The first method is to multiply the logical test by 1. The logical test should be placed in parentheses to ensure the result is always accurate.

=(logical test)*1

Convert logical test multiply by 1

Method 2: Add 2 hyphens before the logical test

The other technique is to write 2 hyphens before the test, as in this example, with the same result

=–(logical test)

Use Hyphen to convert true and false

Using this technique with a SUM function

Now, because we can convert true and false to 0 and 1, we can include logical test in a function like SUM. But this time, we must perform the test on the range of cells, and not only one cell like we did previously.

=SUM(–(B2:B9>=F4))

Logical test inside a SUM function

Of course, you can have a similar result with the COUNTIF function =COUNTIF(B2:B9,">="&F4)

Practice with exercises

Practice logical tests directly in the grid below.

logical tests quiz95

Logical Tests Exercise - Check an employee's details (TRUE/FALSE)

Write 7 independent logical tests (TRUE/FALSE) on one employee's record: empty cells, text comparisons, thresholds and LEFT/RIGHT — 7 guided steps, no fill-down.

Write the logical test in cell G2

1 / 7

In G2, how do you write the logical test that checks whether the email is missing?

Logical tests — Q1 · 683

Write the logical test in cell G3

2 / 7

In G3, how do you write the logical test that checks whether the employee on row 2 is a man? The Gender column (B) contains "Male" or "Female".

Logical tests — Q2 · 684

Write the logical test in cell G4

3 / 7

In G4, how do you write the logical test that checks whether the employee on row 2 is different from "Male"?

Logical tests — Q3 · 685

Write the logical test in cell G5

4 / 7

In G5, how do you write the logical test that checks whether the salary on row 2 is below 2000?

Logical tests — Q4 · 686

Write the logical test in cell G6

5 / 7

In G6, how do you write the logical test that checks whether the postal code on row 2 is equal to 69001?

Logical tests — Q5 · 687

Write the logical test in cell G7

6 / 7

In G7, how do you write the logical test that checks whether the postal code on row 2 starts with 69?

Logical tests — Q6 · 688

Write the logical test in cell G8

7 / 7

In G8, how do you write the logical test that checks whether the email on row 2 ends with "@xyz.com"?

Logical tests — Q7 · 689

Your score is

0%

Related articles

Practice this function

Reading is a good start, but practice is how you remember. These exercises are based on real questions from Excel forums, with instant correction.

Leave a Reply

Your email address will not be published. Required fields are marked *

Convert TRUE/FALSE to 1/0 in Excel

Reading time: 2 minutes

Do you know you can convert the result of a logical test, TRUE or FALSE, to 1 or 0? It’s straightforward and highly useful for utilizing functions like SUM. Two techniques can be used

  1. Multiply the outcome of a logical test by 1
  2. Apply the hyphen method to transform the result (my favorite)👍

Result of a logical test in Excel

In Excel, a logical test returns TRUE or FALSE. For instance, to determine if a customer is 21 years-old or older, we can write the following test with an absolute reference to the limit cell.

Logical test age greater than 21

Training articles

How to convert the test to a numeric value?

Method 1: Multiply by 1

The first method is to multiply the logical test by 1. The logical test should be placed in parentheses to ensure the result is always accurate.

=(logical test)*1

Convert logical test multiply by 1

Method 2: Add 2 hyphens before the logical test

The other technique is to write 2 hyphens before the test, as in this example, with the same result

=–(logical test)

Use Hyphen to convert true and false

Using this technique with a SUM function

Now, because we can convert true and false to 0 and 1, we can include logical test in a function like SUM. But this time, we must perform the test on the range of cells, and not only one cell like we did previously.

=SUM(–(B2:B9>=F4))

Logical test inside a SUM function

Of course, you can have a similar result with the COUNTIF function =COUNTIF(B2:B9,">="&F4)

Practice with exercises

Practice logical tests directly in the grid below.

logical tests quiz95

Logical Tests Exercise - Check an employee's details (TRUE/FALSE)

Write 7 independent logical tests (TRUE/FALSE) on one employee's record: empty cells, text comparisons, thresholds and LEFT/RIGHT — 7 guided steps, no fill-down.

Write the logical test in cell G2

1 / 7

In G2, how do you write the logical test that checks whether the email is missing?

Logical tests — Q1 · 683

Write the logical test in cell G3

2 / 7

In G3, how do you write the logical test that checks whether the employee on row 2 is a man? The Gender column (B) contains "Male" or "Female".

Logical tests — Q2 · 684

Write the logical test in cell G4

3 / 7

In G4, how do you write the logical test that checks whether the employee on row 2 is different from "Male"?

Logical tests — Q3 · 685

Write the logical test in cell G5

4 / 7

In G5, how do you write the logical test that checks whether the salary on row 2 is below 2000?

Logical tests — Q4 · 686

Write the logical test in cell G6

5 / 7

In G6, how do you write the logical test that checks whether the postal code on row 2 is equal to 69001?

Logical tests — Q5 · 687

Write the logical test in cell G7

6 / 7

In G7, how do you write the logical test that checks whether the postal code on row 2 starts with 69?

Logical tests — Q6 · 688

Write the logical test in cell G8

7 / 7

In G8, how do you write the logical test that checks whether the email on row 2 ends with "@xyz.com"?

Logical tests — Q7 · 689

Your score is

0%

Related articles

Practice this function

Reading is a good start, but practice is how you remember. These exercises are based on real questions from Excel forums, with instant correction.

Leave a Reply

Your email address will not be published. Required fields are marked *