Contact

BITOR in Google Sheets: Merge Output Flags and Avoid Overlap Errors

Engineering Intermediate Google Sheets

Combine report masks with Google Sheets BITOR, set flags repeatedly without toggling them and contrast bitwise union with ordinary addition.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: BITOR(value1,value2) retains every bit present in either decimal input. Use it to merge numeric masks or ensure a flag is set. A bit shared by both inputs appears once in the result.

Availability and version history

  • Introduced: first introduction date is not established by the reviewed official history; no desktop release number is inferred.
  • Availability: documented in the rolling Google Sheets service; these examples use the web worksheet workflow.
  • Checked: October 14, 2026; official BITOR reference. Documentation and independent models, with no native Sheets execution or wider client certification.

Syntax and the truth table

=BITOR(value1,value2)

Both arguments are decimal representations. At each bit position, Google’s truth table returns zero only when both input bits are zero. Otherwise it returns one at that position.

The result is a decimal number representing the combined mask. It is not a general logical test like OR. For example, testing two text comparisons with OR answers a different question from combining two numeric encodings.

The short dedicated Google reference does not specify a complete ceiling, fractional-input policy or native error table. These examples stay with small nonnegative integers and do not inherit another product’s constraints.

Example 1: merge report-output configurations

Use fictional weights CSV=1, PDF=2, charts=4, archive=8 and metadata=16. Enter these masks in A1:B4:

A, first configuration B, second configuration
6 18
1 8
22 22

In C2 enter and fill through C4:

=BITOR(A2,B2)

The expected combined masks are 22, 9 and 22. In the first row, 6 contains PDF and charts, while 18 contains PDF and metadata. Their union contains PDF once, plus charts and metadata: 2+4+16=22.

In D2 enter =A2+B2 and fill down. Ordinary addition gives 24, 9 and 44. The middle row agrees because the bits do not overlap. The other rows show why adding two configurations is not a reliable way to merge them.

The first binary comparison is 00110 OR 10010 = 10110. Padding those illustrations to five digits aligns the positions; it does not change the decimal values.

Example 2: ensure archive is selected

Put masks 2, 10, 16 and 24 in F2:F5. Archive has weight 8. In G2 enter and fill down:

=BITOR(F2,8)

The results are 10, 10, 24 and 24. Masks already containing archive do not change. In H2 enter =BITOR(G2,8) and fill down; the outputs remain 10, 10, 24 and 24.

This repeatable behavior is useful when a refresh must ensure a report option remains enabled. BITXOR would toggle the bit instead: applying a toggle again could undo the first operation.

The formula does not itself create an archive or export a file. It changes a numeric configuration value whose interpretation is defined by this example’s option table.

Advanced example: merge binary imports safely

Format J2:K2 as Plain text and enter 00110 and 10010. Convert them before combining:

=BITOR(BIN2DEC(J2),BIN2DEC(K2))

The result is 22. A display formula =DEC2BIN(22,5) returns 10110. Google’s reference explicitly supports combining BITOR with BIN2DEC in this way.

Using decimal 110 and 10010 directly would interpret different input quantities; their digits are not automatically understood as binary because the function name contains BIT. Make the representation conversion explicit.

For three configurations 6, 17 and 8, use =BITOR(BITOR(6,17),8). The first pair gives 23, and adding the archive bit produces 31, with all five fictional options selected.

Advanced check: account for the overlap

For the first table row, a useful independent identity is:

=BITOR(A2,B2)+BITAND(A2,B2)

The shared BITAND mask is 2. The result 22+2=24 equals the ordinary sum 6+18. The intersection explains the exact double-counting of shared bit weights.

For the identical pair 22 and 22, both the union and intersection are 22, so their sum is 44. For 1 and 8, the intersection is zero, so union and addition both yield 9.

Checks and remaining limits

A zero mask contributes no selected bits: =BITOR(22,0) returns 22. Swapping the two inputs leaves the union unchanged. These are consequences of the bitwise truth table, independently checked here.

Keep the option dictionary beside the data and avoid introducing two different meanings for the same bit. If the data uses multiple-bit fields rather than independent flags, merging whole masks may have a different business meaning and needs a separate design.

Native coercion, negative or fractional inputs, oversized results and exact error displays remain unverified. DEC2BIN has its own signed conversion interval; a wider bitwise use case does not automatically fit that representation function.

References and verification

Examples use fictional data, English function names and comma separators. Expected outputs are independent mathematical calculations or explicitly documented rules, not native Sheets captures. Check the spreadsheet locale when reproducing punctuation-sensitive formulas.