OR function
PRO
BASIC
The OR
function in Jspreadsheet Formulas Pro is a logical operator that can help you determine if any of your specified conditions are met. It will return 'true' if at least one of the arguments or conditions you provide is true. If none of the arguments are true, the function will return 'false'. This is useful for validating data or making decisions based on multiple criteria.
Documentation
Returns true if any argument is true, and false otherwise.
Category
Logical
Syntax
OR(logical1, [logical2], ...)
Parameter | Description |
---|---|
logical |
The first condition to be evaluated. |
logicalN |
Optional. An optional condition to be evaluated. |
Behavior
The OR
function is a logical function that is used to test multiple conditions at the same time. It returns 'TRUE' if any of the conditions are true and 'FALSE' if all conditions are false. Below are its behaviors:
- Empty Cells: If the
OR
function is applied to a range of cells that includes empty cells, these empty cells are ignored by the function. - Text: If the function is applied to cells containing text, it treats the text as '0' unless the text is 'TRUE' or 'FALSE', in which case it treats them as logical values.
- Booleans: If the function is applied to cells containing Boolean values (TRUE or FALSE), it treats them as logical values.
- Errors: If any of the arguments in the
OR
function is an error, the function will return an error.
Common Errors
Error | Description |
---|---|
#VALUE! | This error occurs if the given argument is non-numeric and is not a logical value. |
Best practices
- When using the
OR
function, ensure that the arguments are either numbers, logical values, or cell references containing numbers or logical values. Avoid using text strings as they might result in errors.- If you want to test multiple conditions, it's more efficient to use the
OR
function rather than multiple nestedIF
statements.- Be aware that the
OR
function will return 'TRUE' as soon as it encounters the first 'TRUE' condition. Therefore, the order of the conditions can sometimes affect the result.- Always check your function for possible errors to ensure that your formula works smoothly.
Usage
A few examples using the OR function.
OR(1=1,2=3) returns true
OR(1=2,2=3,3=4) returns false
OR(A1="Yes",A2="Yes",A3="Yes") returns true if at least one of the specified cells contains the value "Yes"
Interactive Spreadsheet Demo
<html>
<script src="https://jspreadsheet.com/v11/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://jspreadsheet.com/v11/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/formula-pro/dist/index.min.js"></script>
<div id="spreadsheet"></div>
<script>
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('OTM3ODJmNTQyMTI4ODEzM2ZiZWM0ZWM4M2MzNzIzN2Q1MDZkNzdhYzQxNTRlYTg2NzY3MmNjNzRmZTQzYzBiYzkxMDc3MDAxMjFmNWExNDdjMTUzMjQzNjJjYTM0MWUxOTQzZWNjMzc4YWQ3ZGY1NzJkMGVhNTA2YmExNjUxMGEsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01EY3pNekF6TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
worksheets: [{
data: [
[
"Project A",
"Complete",
"=OR(B1=\"Complete\",C1=\"Complete\")"
],
[
"Project B",
"In Progress",
"=OR(B2=\"Complete\",C2=\"Complete\")"
],
[
"Project C",
"Pending",
"=OR(B3=\"Complete\",C3=\"Complete\")"
],
[
"Project D",
"Complete",
"=OR(B4=\"Complete\",C4=\"Complete\")"
]
]
}]
});
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
// Set license
jspreadsheet.setLicense('OTM3ODJmNTQyMTI4ODEzM2ZiZWM0ZWM4M2MzNzIzN2Q1MDZkNzdhYzQxNTRlYTg2NzY3MmNjNzRmZTQzYzBiYzkxMDc3MDAxMjFmNWExNDdjMTUzMjQzNjJjYTM0MWUxOTQzZWNjMzc4YWQ3ZGY1NzJkMGVhNTA2YmExNjUxMGEsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01EY3pNekF6TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default function App() {
// Spreadsheet array of worksheets
const spreadsheet = useRef();
// Worksheet data
const data = [
[
"Project A",
"Complete",
"=OR(B1=\"Complete\",C1=\"Complete\")"
],
[
"Project B",
"In Progress",
"=OR(B2=\"Complete\",C2=\"Complete\")"
],
[
"Project C",
"Pending",
"=OR(B3=\"Complete\",C3=\"Complete\")"
],
[
"Project D",
"Complete",
"=OR(B4=\"Complete\",C4=\"Complete\")"
]
];
// Render component
return (
<Spreadsheet ref={spreadsheet}>
<Worksheet data={data} />
</Spreadsheet>
);
}
<template>
<Spreadsheet ref="spreadsheet">
<Worksheet :data="data" />
</Spreadsheet>
</template>
<script>
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/vue";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
import formula from "@jspreadsheet/formula-pro";
// Set license
jspreadsheet.setLicense('OTM3ODJmNTQyMTI4ODEzM2ZiZWM0ZWM4M2MzNzIzN2Q1MDZkNzdhYzQxNTRlYTg2NzY3MmNjNzRmZTQzYzBiYzkxMDc3MDAxMjFmNWExNDdjMTUzMjQzNjJjYTM0MWUxOTQzZWNjMzc4YWQ3ZGY1NzJkMGVhNTA2YmExNjUxMGEsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01EY3pNekF6TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default {
components: {
Spreadsheet,
Worksheet,
},
data() {
// Worksheet data
const data = [
[
"Project A",
"Complete",
"=OR(B1=\"Complete\",C1=\"Complete\")"
],
[
"Project B",
"In Progress",
"=OR(B2=\"Complete\",C2=\"Complete\")"
],
[
"Project C",
"Pending",
"=OR(B3=\"Complete\",C3=\"Complete\")"
],
[
"Project D",
"Complete",
"=OR(B4=\"Complete\",C4=\"Complete\")"
]
]
return {
data
};
}
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import * as formula from "@jspreadsheet/formula-pro";
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('OTM3ODJmNTQyMTI4ODEzM2ZiZWM0ZWM4M2MzNzIzN2Q1MDZkNzdhYzQxNTRlYTg2NzY3MmNjNzRmZTQzYzBiYzkxMDc3MDAxMjFmNWExNDdjMTUzMjQzNjJjYTM0MWUxOTQzZWNjMzc4YWQ3ZGY1NzJkMGVhNTA2YmExNjUxMGEsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01EY3pNekF6TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
@Component({
standalone: true,
selector: "app-root",
template: `<div #spreadsheet></div>`
})
export class AppComponent {
@ViewChild("spreadsheet") spreadsheet: ElementRef;
// Worksheets
worksheets: jspreadsheet.worksheetInstance[];
// Create a new data grid
ngAfterViewInit() {
// Create spreadsheet
this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
worksheets: [{
data: [
[
"Project A",
"Complete",
"=OR(B1=\"Complete\",C1=\"Complete\")"
],
[
"Project B",
"In Progress",
"=OR(B2=\"Complete\",C2=\"Complete\")"
],
[
"Project C",
"Pending",
"=OR(B3=\"Complete\",C3=\"Complete\")"
],
[
"Project D",
"Complete",
"=OR(B4=\"Complete\",C4=\"Complete\")"
]
]
}]
});
}
}